Open maurorigo opened 1 year ago
Fixed, downgrading NumPy from 1.24 to 1.21 fixed the issue (although it should work also with up to at least 1.23.5)
Thank you! It sounds like you've tracked down the release notes item related to this. Do you know the recommended way to fix this error for 1.24? I feel we shall fix it before the knowledge and tooling is forgotten.
In previous versions (at least since 1.21.0, I didn't check in earlier versions), there was a VisibleDeprecationWarning
(VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
)
Apparently in 1.24.0 they removed the deprecation warning (https://numpy.org/doc/stable/release/1.24.0-notes.html#expired-deprecations) and it seems that, instead of mask = numpy.bitwise_and.reduce([ki == 0 for ki in k])
, mask = numpy.bitwise_and.reduce(numpy.array([ki == 0 for ki in k], dtype=object))
does the trick, at least from 1.21.0 up to the most recent version. Here's some code that replicates what happens during the testing of nbkit
:
import numpy as np
k = [np.array([[0.]], dtype=np.float32), np.array([[ 0. ], [ 0.02454369], [ 0.04908739], [ 0.07363108],\
[ 0.09817477], [ 0.12271847], [ 0.14726216], [ 0.17180586],\
[ 0.19634955], [ 0.22089323], [ 0.24543694], [ 0.26998064],\
[ 0.2945243 ], [ 0.319068 ], [ 0.34361172], [ 0.3681554 ],\
[ 0.3926991 ], [ 0.4172428 ], [ 0.44178647], [ 0.46633017],\
[ 0.49087387], [ 0.5154176 ], [ 0.5399613 ], [ 0.5645049 ],\
[ 0.5890486 ], [ 0.6135923 ], [ 0.638136 ], [ 0.66267973],\
[ 0.68722343], [ 0.7117671 ], [ 0.7363108 ], [ 0.7608545 ],\
[-0.7853982 ], [-0.7608545 ], [-0.7363108 ], [-0.7117671 ],\
[-0.68722343], [-0.66267973], [-0.638136 ], [-0.6135923 ],\
[-0.5890486 ], [-0.5645049 ], [-0.5399613 ], [-0.5154176 ],\
[-0.49087387], [-0.46633017], [-0.44178647], [-0.4172428 ],\
[-0.3926991 ], [-0.3681554 ], [-0.34361172], [-0.319068 ],\
[-0.2945243 ], [-0.26998064], [-0.24543694], [-0.22089323],\
[-0.19634955], [-0.17180586], [-0.14726216], [-0.12271847], [-0.09817477],\
[-0.07363108], [-0.04908739], [-0.02454369]], dtype=np.float32),\
np.array([[ 0. , 0.02454369, 0.04908739, 0.07363108, 0.09817477,\
0.12271847, 0.14726216, 0.17180586, 0.19634955, 0.22089323,\
0.24543694, 0.26998064, 0.2945243 , 0.319068 , 0.34361172,\
0.3681554 , 0.3926991 , 0.4172428 , 0.44178647, 0.46633017,\
0.49087387, 0.5154176 , 0.5399613 , 0.5645049 , 0.5890486 ,\
0.6135923 , 0.638136 , 0.66267973, 0.68722343, 0.7117671 ,\
0.7363108 , 0.7608545 , -0.7853982 ]], dtype=np.float32)]
print(k)
print([np.shape(ki) for ki in k])
mask = np.bitwise_and.reduce([ki == 0 for ki in k]) # Raises a deprecation warning up to 1.23.5, gives value error above
mask = np.bitwise_and.reduce(np.array([ki == 0 for ki in k], dtype=object)) # Works at least from 1.21.0
print(mask, mask.shape)
Hello, I'm trying to run tests for the library with MPI on a cluster. Running
python runtests.py --single --pdb --capture=no
(this happens also for multiple ranks), when testingnbkit
I get this error:Does anybody have an idea why this happens?