Skip to content

Remove deprecated numpy.bool from type map

David Gobbi requested to merge dgobbi/vtk:numpy-bool-deprecated into master

Numpy 1.20 has deprecated numpy.bool, causing deprecation warnings when numpy_support.py is used. The conversion from vtkBitArray to an array of numpy.bool was in fact never implemented, per the code comments at line 16 in numpy_support.py:

 - Bit arrays in general do not have a numpy equivalent and are not
   supported.  Char arrays are also not easy to handle and might not
   work as you expect.  Patches welcome.

Attempts to convert vtkBitArray to numpy will raise an exception saying 'Bit arrays are not supported.'

This MR fixes the deprecation warning by changing the VTK_BIT -> numpy.bool mapping to VTK_BIT -> numpy.uint8, since uint8 is the type that numpy uses for packed bit arrays, but it does not implement the conversion. The 'Bit arrays are not supported' message is still in place.

Resolves #18268 (closed)

Edited by David Gobbi

Merge request reports