Description
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:
import numpy as np
import types
assert isinstance(np.size, types.FunctionType)
Error message:
N/A
Runtime information:
[{'numpy_version': '1.25.0.dev0+831.g3b5eff00e',
'python': '3.9.13 | packaged by conda-forge | (main, May 27 2022, '
'16:56:21) \n'
'[GCC 10.3.0]',
'uname': uname_result(system='Linux', node='janet', release='6.0.12-76060006-generic', version='#202212290932~1674139725~22.04~ca93ccf SMP PREEMPT_DYNAMIC Thu J', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}},
{'architecture': 'Haswell',
'filepath': '/home/davidh/miniconda3/envs/satpy_py39_unstable2/lib/python3.9/site-packages/numpy.libs/libopenblas64_p-r0-15028c96.3.21.so',
'internal_api': 'openblas',
'num_threads': 12,
'prefix': 'libopenblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.21'}]
Context for the issue:
I'm not sure how many packages have code like this, but holoviews has this bit of code:
aggregator = param.ClassSelector(
default=np.size, class_=(types.FunctionType, tuple), doc="""
Aggregation function or dimension transform used to compute bin
values. Defaults to np.size to count the number of values
in each bin.""")
And the param
library does this check between that class_
tuple and the default
object (in this case np.size
):
if is_instance:
if not (isinstance(val, class_)):
raise ValueError(
"%s parameter %r value must be an instance of %s, not %r." %
(param_cls, self.name, class_name, val))
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.