eric-wieser / ros_numpy

Tools for converting ROS messages to and from numpy arrays
MIT License
303 stars 158 forks source link

change np.float to np.float32 #38

Closed Luca-Pozzi closed 1 year ago

Luca-Pozzi commented 1 year ago

Since numpy 1.20, using np.float is deprecated. With newer versions (tested on Python 3.8.10, numpy 1.24) this lead to the following error message:

Traceback (most recent call last): File "", line 1, in File "/home/luca/tiago_public_ws/devel/lib/python3/dist-packages/ros_numpy/init.py", line 34, in exec(fh.read()) File "", line 7, in File "/home/luca/tiago_public_ws/src/ros_numpy/src/ros_numpy/point_cloud2.py", line 224, in def get_xyz_points(cloud_array, remove_nans=True, dtype=np.float): File "/home/luca/.local/lib/python3.8/site-packages/numpy/init.py", line 305, in getattr raise AttributeError(__former_attrs[attr]) AttributeError: module 'numpy' has no attribute 'float'. np.float was a deprecated alias for the builtin float. To avoid this error in existing code, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Replacing the np.float alias with float makes the package compatible also with newer numpy versions.