-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Open
Description
Steps to reproduce:
In numpy>=1.25
, this is the behavior:
>>> import numpy as np
>>> type(np.mean)
<class 'numpy._ArrayFunctionDispatcher'>
>>> import inspect
>>> inspect.isfunction(np.mean)
False
>>> inspect.ismethod(np.mean)
False
>>> from numpy import _ArrayFunctionDispatcher
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name '_ArrayFunctionDispatcher' from 'numpy' (/home/adrin/miniforge3/envs/skops/lib/python3.11/site-packages/numpy/__init__.py)
I would think inspect.isfunction(np.mean)
should return True
, maybe?
Also, it's odd that the type(np.mean)
returns something which cannot be imported, and the actual import is from numpy.core._multiarray_umath import _ArrayFunctionDispatcher
.
Ended up observing this since our dispatch mechanism in skops
which was dispatching ufunc
was ignored since these are no more ufunc
s (I think they were before?)