-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: np.size is no longer an instance of FunctionType (nightly/dev build) #23307
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
Just to be sure it wasn't some weird Python 3.9 thing, here's a 3.11 environment: conda create -n numpy_dev_py311 python=3.11 numpy
conda activate numpy_dev_py311
conda uninstall -y --force numpy
python -m pip install --index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple/ --trusted-host pypi.anaconda.org --no-deps --pre --upgrade numpy
python -c "import numpy as np; import types; print(isinstance(np.size, types.FunctionType))" Prints |
This is happening because of #23020, which moved the
#23032 is related as well, since the same change also impacted sphinx. |
I'm not sure Maybe it will require more work in holoviews. Edit: Actually a |
Note that |
I honestly have no idea. Holoviews is used in one small part of one small utility function of the library I work on. Otherwise, I guess technically this could trigger edge cases in any library that likes to pass function pointers around. I did notice something interesting, if you print out the >>> import numpy as np
>>> np.size
<function size at 0x7f711b14cc30>
>>> np.size.__class__
<class 'numpy._ArrayFunctionDispatcher'>
>>> np.size.__class__.__class__
<class 'type'> But I guess Ok enough rambling...I'm sure there will be other cases of this change causing issues downstream but the fact that no one has brought it up before me suggests you/we won't find out until release. |
The issues in holoviews have now been fixed by using |
That is not possible, nor is it something Python does. Check |
Wow, this led me down a short rabbit hole. Python (def/lambda) functions versus all other types of callables. Interesting. Thanks. |
Describe the issue:
I have a package that has a CI environment that installs numpy and many other packages from their current unstable/dev versions (nightly builds) and runs the tests. A couple months ago (I think) we started running into a failure where one of our dependencies (holoviews) started crashing when performing the check
isinstance(np.size, types.FunctionType)
. We are not installing a dev version of holoviews. It seems to be tied to numpy's dev version.Reproduce the code example:
Error message:
Runtime information:
Context for the issue:
I'm not sure how many packages have code like this, but holoviews has this bit of code:
https://github.com/holoviz/holoviews/blob/4e83af3e6af0e19fa6c7e226791011372916fc70/holoviews/plotting/bokeh/hex_tiles.py#L26-L30
And the
param
library does this check between thatclass_
tuple and thedefault
object (in this casenp.size
):https://github.com/holoviz/param/blob/cd1b4ae50c01c14c0eb22721e41a9c8fb1e8f738/param/__init__.py#L1381-L1385
I am not a holoviews developer, just use it for one small portion of my package (Satpy). As far as I can tell
np.size
is defined as a function here:numpy/numpy/core/fromnumeric.py
Lines 3194 to 3195 in 486878b
So I'm lost as to where/how this is not being satisfied. I've seen the failure on Python 3.9 environments. I have not tried other versions of Python.
The text was updated successfully, but these errors were encountered: