tfcausalimpact icon indicating copy to clipboard operation
tfcausalimpact copied to clipboard

TypeError: ufunc 'isfinite' not supported for the input types

Open Queely1 opened this issue 2 years ago • 5 comments

Good afternoon, after the update, the following error occurred.

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''.

The code worked fine before. Summary and report are also shown, the error appears only when you try to draw a graph.

Rollback to the previous version could not, the error now appears on any versions. image image

Queely1 avatar Dec 21 '22 13:12 Queely1

Hi @Queely1 ,

I noticed it yesterday as well and opened an issue for the numpy repository, this is a bug for version 1.24.

Just reinstall previous version:

pip install -U numpy==1.23.4

And things should be back to normal.

They are already working on a fix for this issue so I'm hoping this will be solved soon.

Let me know how this works for you.

WillianFuks avatar Dec 21 '22 13:12 WillianFuks

Works, thanks a lot!

Queely1 avatar Dec 21 '22 14:12 Queely1

It is also breaking float64 types:

SingleBlockManager
Items: Float64Index([ -2.408224685280692, -2.3739711708557603, -2.3397176564308286,
               -2.305464142005897,  -2.271210627580966,  -2.236957113156034,
              -2.2027035987311026,  -2.168450084306171, -2.1341965698812393,
              -2.0999430554563077,
              ...
                4.099943055456308,   4.134196569881238,   4.168450084306171,
                4.202703598731102,   4.236957113156034,   4.271210627580965,
                4.305464142005897,   4.339717656430828,   4.373971170855761,
               4.4082246852806914],
             dtype='float64', length=200)
NumericBlock: 200 dtype: float64
  res = masked_where(~(np.isfinite(getdata(a))), a, copy=copy)

E TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

ecarruda avatar Dec 21 '22 14:12 ecarruda

Hi @ecarruda ,

Just to confirm, is it still breaking after downgrading the numpy version?

WillianFuks avatar Dec 21 '22 15:12 WillianFuks

Hi,

I just ran into the same issue and using .values when plotting confidence intervals, e.g.:

ax.fill_between(
            pre_post_index[1:],
            inferences['complete_preds_lower'].iloc[1:].values,
            inferences['complete_preds_upper'].iloc[1:].values,
            color=color,
            alpha=0.4
)

seems to solve the issue without downgrading the numpy version.

waral avatar Dec 23 '22 12:12 waral