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

Fix numpy 1.24 warnings #1218

Merged
merged 3 commits into from
May 22, 2023
Merged

Fix numpy 1.24 warnings #1218

merged 3 commits into from
May 22, 2023

Conversation

ianthomas23
Copy link
Member

Fixes #1216.

Summary of fixes:

  • Conversion of float array containing NaN to integer:

    • Simple uses now have a call to np.nan_to_number to convert np.nan to 0, which is the number that has always been returned in this scenario.
    • The more complicated code in category_binning already determines a mask of the NaN values, so those NaN values are set to 0 (they could be any valid finite number) before the conversion to int.
    • In Canvas.raster we avoid the warning by using a fill_value of 0 for integer dtypes as that is what the docstring says is used in this scenario.
  • Warnings about finding max or min of an "all-nan slice" are specifically ignored as they already return the expected value of nan in this situation.

@@ -11,6 +11,10 @@
except ImportError:
rioxarray = None

from dask.context import config

config.set(scheduler='synchronous')
Copy link
Member Author

Choose a reason for hiding this comment

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

This is consistent with what is in test_dask.py.

@codecov
Copy link

codecov bot commented May 19, 2023

Codecov Report

Merging #1218 (26c8f4a) into main (8092f4d) will increase coverage by 0.32%.
The diff coverage is 95.35%.

@@            Coverage Diff             @@
##             main    #1218      +/-   ##
==========================================
+ Coverage   84.52%   84.85%   +0.32%     
==========================================
  Files          35       35              
  Lines        8369     8570     +201     
==========================================
+ Hits         7074     7272     +198     
- Misses       1295     1298       +3     
Impacted Files Coverage Δ
datashader/data_libraries/pandas.py 100.00% <ø> (ø)
datashader/reductions.py 84.70% <93.24%> (+1.59%) ⬆️
datashader/compiler.py 91.07% <100.00%> (+0.50%) ⬆️
datashader/core.py 88.28% <100.00%> (+0.04%) ⬆️
datashader/data_libraries/dask.py 95.23% <100.00%> (+0.07%) ⬆️
datashader/data_libraries/dask_xarray.py 98.95% <100.00%> (ø)
datashader/transfer_functions/__init__.py 87.03% <100.00%> (+0.12%) ⬆️
datashader/utils.py 81.86% <100.00%> (+2.61%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RuntimeWarning: invalid value encountered in cast
1 participant