-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Closed
Labels
Description
Describe the issue:
Before version 1.24, numpy.masked_invalid
was converting its input to a numpy array, which allowed to pass array-like input.
Changes in #22046 breaks this, which makes for instance some function in matplotlib fails with pandas series (for instance fill_betweenx
.
I don't know if this is an intended change to only support np.array
here, but I just wanted to document this.
I will also report to the matplotlib
developpers.
Reproduce the code example:
import numpy as np
import pandas as pd
np.ma.masked_invalid(pd.Series([1, 2, 3]))
Error message:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 np.ma.masked_invalid(pd.Series([1, 2, 3]))
File ~/.local/miniconda/envs/test_benchopt/lib/python3.11/site-packages/numpy/ma/core.py:2360, in masked_invalid(a, copy)
2332 def masked_invalid(a, copy=True):
2333 """
2334 Mask an array where invalid values occur (NaNs or infs).
2335
(...)
2357
2358 """
-> 2360 return masked_where(~(np.isfinite(getdata(a))), a, copy=copy)
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''
NumPy/Python version information:
This starts to fail with numpy 1.24. Working with previous version.
Context for the issue:
No response