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

Replace depracated Numpy dtypes #395

Merged
merged 4 commits into from
Nov 17, 2021
Merged

Conversation

pnuu
Copy link
Member

@pnuu pnuu commented Nov 11, 2021

With a new production chain I noticed the following depraction warning in the logs:

lib/python3.9/site-packages/pyresample/kd_tree.py:968: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  radius=self.radius_of_influence, dtype=np.int,

This PR replaces all the usages of np.int, np.float and np.bool with the preferred versions listed in the third column of the Release Notes for 1.20.0.

  • Tests passed
  • Passes git diff origin/main **/*py | flake8 --diff

@pnuu pnuu self-assigned this Nov 11, 2021
@djhoese
Copy link
Member

djhoese commented Nov 11, 2021

Do we just want to force this to int64 to ensure 64-bit precision?

@djhoese
Copy link
Member

djhoese commented Nov 11, 2021

I also think there is an np.float somewhere in kd_tree.py somewhere but when I switched it to float64 it started failing...I think.

@codecov
Copy link

codecov bot commented Nov 12, 2021

Codecov Report

Merging #395 (015efc2) into main (ee7c1b9) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #395   +/-   ##
=======================================
  Coverage   93.80%   93.80%           
=======================================
  Files          65       65           
  Lines       11038    11061   +23     
=======================================
+ Hits        10354    10376   +22     
- Misses        684      685    +1     
Flag Coverage Δ
unittests 93.80% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pyresample/future/resamplers/nearest.py 92.27% <ø> (ø)
pyresample/kd_tree.py 92.02% <ø> (ø)
pyresample/_spatial_mp.py 83.57% <100.00%> (ø)
pyresample/bilinear/xarr.py 92.24% <100.00%> (ø)
pyresample/bucket/__init__.py 97.56% <100.00%> (ø)
pyresample/test/test_kd_tree.py 97.31% <100.00%> (ø)
pyresample/test/utils.py 75.70% <0.00%> (-0.94%) ⬇️
pyresample/spherical.py 97.81% <0.00%> (ø)
pyresample/test/test_geometry.py 99.30% <0.00%> (+<0.01%) ⬆️
pyresample/geometry.py 86.61% <0.00%> (+0.21%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee7c1b9...015efc2. Read the comment docs.

@coveralls
Copy link

coveralls commented Nov 12, 2021

Coverage Status

Coverage increased (+0.006%) to 93.611% when pulling 015efc2 on pnuu:fix-deprecated-np-int into ee7c1b9 on pytroll:main.

@pnuu
Copy link
Member Author

pnuu commented Nov 12, 2021

I changed them to np.int64 and np.float64 to be explicit. And swapped np.bool to np.bool_ to be consistent with the others.

Apparently pytest-lazy-fixture was missing from the test_requires as I couldn't run the tests locally. As the tests ran on CI, I assume it was explicitly installed there.

@pnuu
Copy link
Member Author

pnuu commented Nov 12, 2021

The tests don't pass locally on Python 3.9, which doesn't seem to be use in the CI at all!

@pnuu
Copy link
Member Author

pnuu commented Nov 12, 2021

Python 3.9 test runs added in #396

@pnuu pnuu changed the title Use int instead of deprecated np.int Replace depracated Numpy dtypes Nov 12, 2021
Comment on lines 129 to 130
x_idxs = da.floor((proj_x - adef.area_extent[0]) / x_res).astype(int)
y_idxs = da.floor((adef.area_extent[3] - proj_y) / y_res).astype(int)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want these to be np.int64 too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Thanks, missed them in the previous change 🤦‍♂️

Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small double check on one remaining int, otherwise LGTM

setup.py Show resolved Hide resolved
@djhoese djhoese merged commit 1c7b8f9 into pytroll:main Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants