numpy.bool is deprecated
The usage of numpy.bool
has been deprecated as of Numpy 1.20. Instead, it's recommended to either use the built in python bool
or use the numpy scalar numpy.bool_
.
~/.local/src/miniconda3/lib/python3.9/site-packages/vtkmodules/util/numpy_support.py in get_vtk_to_numpy_typemap()
72 def get_vtk_to_numpy_typemap():
73 """Returns the VTK array type to numpy array type mapping."""
---> 74 _vtk_np = {vtkConstants.VTK_BIT:numpy.bool,
75 vtkConstants.VTK_CHAR:numpy.int8,
76 vtkConstants.VTK_SIGNED_CHAR:numpy.int8,
~/.local/src/miniconda3/lib/python3.9/site-packages/numpy/__init__.py in __getattr__(attr)
285 pass
286 else:
--> 287 warnings.warn(msg, DeprecationWarning, stacklevel=2)
288 return val
289
DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_
` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
Not sure which is preferable in this context though. bool
would be the direct replacement and prevent any compatibility issues with previous versions of numpy (I'm not sure when np.bool_
was introduced, maybe it's always been there).
Supposedly, bool
is the same size as int
(so normally 4 bytes), while the numpy.bool_
is only one byte long. So using the lower memory footprint may be desirable. But I can't seem to "prove" that there is any difference in the memory allocation, as np.ones(100, dtype=bool).nbytes
and np.ones(100, dtype=np.bool_).nbytes
both return with 100 bytes.