pycroscopy/atomai

Numpy deprecation error

ercius opened this issue · 2 comments

ercius commented

I installed atomai 0.7.4 and numpy 1.26.0. Im running the tutorial to make sure everything works and ran into an error.

For multivariate analysis you run this line:
imstack = aoi.stat.imlocal(nn_output, coordinates, window_size=32, coord_class=1)

With numpy 1.26.0 this outputs the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[28], line 1
----> 1 imstack = aoi.stat.imlocal(nn_output, coordinates, window_size=32, coord_class=1)

File /opt/tljh/user/envs/atomai/lib/python3.10/site-packages/atomai/stat/multivar.py:87, in imlocal.__init__(self, network_output, coord_class_dict_all, window_size, coord_class)
     85 self.nb_classes = network_output.shape[-1]
     86 self.coord_all = coord_class_dict_all
---> 87 self.coord_class = np.float(coord_class)
     88 self.r = window_size
     89 (self.imgstack,
     90  self.imgstack_com,
     91  self.imgstack_frames) = self.extract_subimages_()

File /opt/tljh/user/envs/atomai/lib/python3.10/site-packages/numpy/__init__.py:324, in __getattr__(attr)
    319     warnings.warn(
    320         f"In the future `np.{attr}` will be defined as the "
    321         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    323 if attr in __former_attrs__:
--> 324     raise AttributeError(__former_attrs__[attr])
    326 if attr == 'testing':
    327     import numpy.testing as testing

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

The fix is easy but needs to be implemented.

Thanks for reporting it, Peter! The fix has been implemented on the master branch but hasn't been 'released' yet. Will do it this weekend.

This should now be fixed in the new release.