1.20 spurious "np.bool deprecated" warning
See original GitHub issueI have some code which is tested against CI (pytest) and noticed some warnings occurring once numpy 1.20 was introduced. A typical warning
some-file.py:131: 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.
but the lines following do not include np.bool
, indeed, a git grep confirms that np.bool
is nowhere mentioned in the repo.
Some example lines reported:
return self.array[0]
return self.array[-1]
i = bisect_left(self.array, v)
if 2 * v < a[i] + a[j]:
α = (v - a[i]) / (a[j] - a[i])
and in multiple cases (15 in fact), I get a summary of the the error counts in the files:
test/test_bathymetry.py::test_xy
.../bathymetry.py:119: DeprecationWarning: `np.bool` is a deprecated alias ...
:
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/../1.20.0-notes.html#deprecations
return self.array[-1]
test/test_bathymetry.py: 129 warnings
test/test_position.py: 16 warnings
test/test_sd5.py: 2037 warnings
It is always bathymetry.py
which is listed at the start the warning, and these same 3 test-files which follow it.
The file bathymetry.py
seems unremarkable; it imports only the NetCDF4 package (not Numpy), and has some unicode variable names. It is itself imported by sd5.py
which also imports Numpy; A bit of a baffler.
This is commercial code, I can’t post the entirety of it here, but I’d be more than willing to experiment against it if anyone has an idea of what is going on.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Actually, looks like this was fixed a couple of weeks ago in netCDF4 , just not made its way into the package yet. So please close this.
Linking to the PR for future reference: Unidata/netcdf4-python#1066, this is marked for release with netCDF4 1.5.6