Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation warning on np.float #50

Open
mauroalberti opened this issue Mar 17, 2023 · 2 comments
Open

Deprecation warning on np.float #50

mauroalberti opened this issue Mar 17, 2023 · 2 comments

Comments

@mauroalberti
Copy link

There is an error related to numpy that has removed the attribute 'float'. Probably just substituting for np.float64 suffice.

/usr/local/lib/python3.8/dist-packages/mplstereonet/stereonet_axes.py in plane(self, strike, dip, *args, **kwargs)
423 segments = kwargs.pop('segments', 100)
424 center = self._center_latitude, self._center_longitude
--> 425 lon, lat = stereonet_math.plane(strike, dip, segments, center)
426 return self.plot(lon, lat, *args, **kwargs)
427

/usr/local/lib/python3.8/dist-packages/mplstereonet/stereonet_math.py in plane(strike, dip, segments, center)
158 lon0, lat0 = center
159 strikes, dips = np.atleast_1d(strike, dip)
--> 160 lons = np.zeros((segments, strikes.size), dtype=np.float)
161 lats = lons.copy()
162 for i, (strike, dip) in enumerate(zip(strikes, dips)):

/usr/local/lib/python3.8/dist-packages/numpy/init.py in getattr(attr)
282 return Tester
283
--> 284 raise AttributeError("module {!r} has no attribute "
285 "{!r}".format(name, attr))
286

AttributeError: module 'numpy' has no attribute 'float'

thanks,
mauro

@ICWallis
Copy link

ICWallis commented Sep 12, 2023

Also appears to impact the method ax.density_contourf()

Error output below. mplstereonet version 0.6.2. numpy version 1.25.2.


AttributeError Traceback (most recent call last)

File c:\Users\Irene\miniconda3\envs\sandpit\lib\site-packages\mplstereonet\stereonet_axes.py:815, in StereonetAxes.density_contourf(self, *args, **kwargs)
677 def density_contourf(self, *args, **kwargs):
678 """
679 Estimates point density of the given linear orientation measurements
680 (Interpreted as poles, lines, rakes, or "raw" longitudes and latitudes
(...)
813 Geophysical Research, Vol. 64, No. 11, pp. 1891--1909.
814 """
--> 815 lon, lat, totals, kwargs = self._contour_helper(args, kwargs)
816 return self.contourf(lon, lat, totals, **kwargs)

File c:\Users\Irene\miniconda3\envs\sandpit\lib\site-packages\mplstereonet\stereonet_axes.py:535, in StereonetAxes._contour_helper(self, args, kwargs)
533 contour_kwargs['gridsize'] = kwargs.pop('gridsize', 100)
534 contour_kwargs['weights'] = kwargs.pop('weights', None)
--> 535 lon, lat, totals = contouring.density_grid(*args, **contour_kwargs)
536 return lon, lat, totals, kwargs

File c:\Users\Irene\miniconda3\envs\sandpit\lib\site-packages\mplstereonet\contouring.py:169, in density_grid(*args, **kwargs)
162 sigma = kwargs.get('sigma', 3)
163 func = {'linear_kamb':_linear_inverse_kamb,
164 'square_kamb':_square_inverse_kamb,
165 'schmidt':_schmidt_count,
166 'kamb':_kamb_count,
167 'exponential_kamb':_exponential_kamb,
168 }[method]
--> 169 lon, lat, z = _count_points(lon, lat, func, sigma, gridsize, weights)
171 if method not in ('schmidt', 'kamb'):
172 # This is really a bit of a plotting hack. We don't want to ever draw
173 # a 0 contour for smoothed methods, as it isn't well defined.
174 z[z == 0] = np.finfo(z.dtype).tiny

File c:\Users\Irene\miniconda3\envs\sandpit\lib\site-packages\mplstereonet\contouring.py:17, in _count_points(lons, lats, func, sigma, gridsize, weights)
15 weights = 1
16 # Normalize the weights
---> 17 weights = np.asarray(weights, dtype=np.float)
18 weights /= weights.mean()
20 # Generate a regular grid of "counters" to measure on...

File c:\Users\Irene\miniconda3\envs\sandpit\lib\site-packages\numpy_init_.py:319, in getattr(attr)
314 warnings.warn(
315 f"In the future np.{attr} will be defined as the "
316 "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
318 if attr in former_attrs:
--> 319 raise AttributeError(former_attrs[attr])
321 if attr == 'testing':
322 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

@ICWallis
Copy link

Workaround: Specifying numpy=1.19.5 (depreciation is in 1.2).

https://numpy.org/devdocs/release/1.20.0-notes.html

Will pr to make the change from np.float64 to float. According to the docs, float has the same precision as float64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants