question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

1.20 spurious "np.bool deprecated" warning

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jjg-dressipicommented, Feb 1, 2021

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.

0reactions
mattipcommented, Feb 2, 2021

Linking to the PR for future reference: Unidata/netcdf4-python#1066, this is marked for release with netCDF4 1.5.6

Read more comments on GitHub >

github_iconTop Results From Across the Web

DeprecationWarning: `np.bool` - python - Stack Overflow
It seems you have an old version of spacepy. They fixed this deprecation warning in their Github code on 1 March 2021 (they...
Read more >
numpy.bool is deprecated (#18268) · Issues · VTK / VTK - GitLab
The usage of numpy.bool has been deprecated as of Numpy 1.20. Instead, it's recommended to either use the built in python bool or...
Read more >
I've been getting some odd warnings (thousands of them) from ...
I've been getting some odd warnings (thousands of them) from CI runs against 1.20, typical: some-file.py:83: DeprecationWarning: `np.bool` is a deprecated ...
Read more >
NumPy 1.16.0 Release Notes
It was deprecated previously, but no warning was issued. The positive operator ( + ) applied to non-numerical arrays is deprecated. See below...
Read more >
Spatial Feature Engineering
Deprecated in NumPy 1.20; for more details and guidance: ... is a deprecated alias for the builtin `bool`. To silence this warning, use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found