-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Attributes on the objects dispatched via _ArrayFunctionDispatcher #24019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It quacks enough to pass |
Well, we're dispatching based on the type of objects, in this case |
Ah well, I don't mind adding it somewhere, but also don't know a particularly good place that is clearly "public". |
|
I think this type should not be exposed. We should be free to make this kind of change to what is internal infrastructure, so using |
@rgommers this type is exposed via |
With current >>> type(np.mean)
<class 'numpy._ArrayFunctionDispatcher'>
>>> from numpy._core.overrides import _ArrayFunctionDispatcher
>>> type(np.mean) is _ArrayFunctionDispatcher
True
>>> from numpy._core._multiarray_umath import _ArrayFunctionDispatcher
>>> type(np.mean) is _ArrayFunctionDispatcher
True The
I would not call that "exposed". Using |
The module is hard-coded in the C type structure, very simple to change for someone who wants to. |
Numpy functions like np.sum are no longer of type FunctionType since Numpy moved dispatcher implementation to C in 1.25 [0,1] Add "type(np.sum)" in addition to types.FunctionType to use the same path for Nnumpy functions in numpy 1.25. [0] numpy/numpy@60a858a [1] numpy/numpy#24019 Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Numpy functions like np.sum are no longer of type FunctionType since Numpy moved dispatcher implementation to C in 1.25 [0,1] Add "type(np.sum)" in addition to types.FunctionType to use the same path for Nnumpy functions in numpy 1.25. [0] numpy/numpy@60a858a [1] numpy/numpy#24019 Closes: PrincetonUniversity#2908 Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Numpy functions like np.sum are no longer of type FunctionType since Numpy moved dispatcher implementation to C in 1.25 [0,1] Add "type(np.sum)" in addition to types.FunctionType to use the same path for Numpy functions in numpy 1.25. [0] numpy/numpy@60a858a [1] numpy/numpy#24019 Closes: #2908 Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Steps to reproduce:
In
numpy>=1.25
, this is the behavior:I would think
inspect.isfunction(np.mean)
should returnTrue
, maybe?Also, it's odd that the
type(np.mean)
returns something which cannot be imported, and the actual import isfrom numpy.core._multiarray_umath import _ArrayFunctionDispatcher
.Ended up observing this since our dispatch mechanism in
skops
which was dispatchingufunc
was ignored since these are no moreufunc
s (I think they were before?)The text was updated successfully, but these errors were encountered: