You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AttributeError: module 'numpy' has no attribute 'float'. #589
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
fig = plt.figure(figsize=(8, 6), edgecolor="w")
m = Basemap(projection="moll", resolution=None, lat_0=0, lon_0=0)
m.drawmapboundary()
m.shadedrelief(scale=0.2)
The error message:
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
I belive, the wrong attribute is used in packages/basemap/src/mpl_toolkits/basemap/__init__.py, master branch, line 4186.
@quickbrett thanks for raising this issue and proposing the fix and @molinav thanks for maintaining this still great package. I actually got the same error, I think it is related to the latest numpy versions.
Hopefully I can get some time soon to start a basic unit test collection, because these issues would be identified immediately with the automatic tests.
@quickbrett I just added the patch in a hotfix branch (1.3.9), your small example now works after the correction. I took this moment to correct all the references to numpy.float that I found in the whole library, mostly replaced with numpy.float64.
I am not sure when I will release 1.3.9, maybe I will do a couple of bugfixes more that are still around before tagging.
@quickbrett I have just added a couple of unit tests for Basemap.shadedrelief based on your snippet, so I am finally closing this issue. The bugfix will come with basemap 1.3.9 (hopefully soon).
Activity
molinav commentedon Oct 1, 2023
Thanks for pointing the bug! Just out of curiosity, which
numpyversion are you using?quickbrett commentedon Oct 1, 2023
I'm using the following versions:
moritzhuetten commentedon Oct 1, 2023
@quickbrett thanks for raising this issue and proposing the fix and @molinav thanks for maintaining this still great package. I actually got the same error, I think it is related to the latest numpy versions.
molinav commentedon Oct 2, 2023
It seems that
numpy.floatwas removed with its release 1.24.0 (https://numpy.org/devdocs/release/1.24.0-notes.html). I will replace it with the Python builtinfloatas suggested in the link.Hopefully I can get some time soon to start a basic unit test collection, because these issues would be identified immediately with the automatic tests.
Fix references to removed numpy.float alias
molinav commentedon Oct 2, 2023
@quickbrett I just added the patch in a hotfix branch (1.3.9), your small example now works after the correction. I took this moment to correct all the references to
numpy.floatthat I found in the whole library, mostly replaced withnumpy.float64.I am not sure when I will release 1.3.9, maybe I will do a couple of bugfixes more that are still around before tagging.
quickbrett commentedon Oct 3, 2023
@molinav I installes the hotfix branch
Hence I'm using the following package versions (
pip list):I tested the new version with a few simple examples and it worked for me.
Thanks!
molinav commentedon Nov 19, 2023
@quickbrett I have just added a couple of unit tests for
Basemap.shadedreliefbased on your snippet, so I am finally closing this issue. The bugfix will come withbasemap1.3.9 (hopefully soon).