ShervanGharari/EASYMORE

Minor Issue: numpy depreciation warning

Closed this issue · 4 comments

Would be nice to resolve as it adds up in the log file.

/globalhome/drc858/HPC/geopandas-env/lib/python3.7/site-packages/easymore/easymore.py:374: DeprecationWarning: np.bool is a deprecated alias for the builtin bool. To silence this warning, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool_ here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
lat_value = np.array(ncid.variables[self.var_lat])
/globalhome/drc858/HPC/geopandas-env/lib/python3.7/site-packages/easymore/easymore.py:375: DeprecationWarning: np.bool is a deprecated alias for the builtin bool. To silence this warning, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool_ here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
lon_value = np.array(ncid.variables[self.var_lon])

Greetings!
Thank you very much for your interest in easymore!
I did not see this warning, do you have a more specific detail of your configuration; numpy version for example. Alternatively I can improve the part of the code mentioned in this issue.

Hi Shervan, the depreciation warning is listed in the attached release notes https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
Simply it seems np.bool is a depreciated alias for bool. So substituting np.bool for bool would avoid any further issue. I can get you a more detailed stacktrace (versions, etc), however the messaging seems explanatory.

This is most likely due to netCDF4 using np.bool, not EASYMORE: Unidata/netcdf4-python@d50b949

This warning won't appear with older versions of Numpy that don't include this change to np.bool yet. It will solve itself in newer version of netCDF4.

I have checked this for version 1.0.0 and latest dependencies. I do not get this warning. Let me know if that is still the case. If resolved, I will close this issue. Than you.
To check this on Mac you can do the following in terminal (assuming you already have [the latest] gdal):

rm -rf EASYMORE # in case there is EASYMORE folder
git clone https://github.com/ShervanGharari/EASYMORE.git
cd EASYMORE
python -m pip install virtualenv
python -m virtualenv test3
source test3/bin/activate
python -m pip install --upgrade pip
python -m pip install jupyter
python -m pip install ipykernel
python -m pip install easymore
python -m ipykernel install --name=test3
jupyter kernelspec list
cd examples
jupyter nbconvert *.ipynb --to python
python 00_test_example.py 
python 01_ERA5_Regular_Lat_Lon.py
python 02_ERA5_Regular_Lat_Lon_NaN.py
python 03_WRF_Rotated_Lat_Lon.py