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 geocentric_resolution compatibility with numpy 2.1.0 #614

Merged
merged 3 commits into from
Aug 24, 2024

Conversation

djhoese
Copy link
Member

@djhoese djhoese commented Aug 23, 2024

Satpy unstable environment started failing and regular environments will start failing too when conda-forge has numpy 2.1.0 available.

Starting with numpy 2.1.0 the numpy function histogram_bin_edges will raise a ValueError if the array you give it can't be split into the number of buckets you request (default 10). This happens when the elements of an array are so close together (near floating point precision) that numpy can't possibly split things into N buckets. There error you get is:

E               ValueError: Too many bins for data range. Cannot create 10 finite-sized bins.

This PR works around this by adding a try/except to the call and just returning the two elements of the input array. As far as I can tell this is basically equivalent.

  • Closes #xxxx
  • Tests added
  • Tests passed
  • Passes git diff origin/main **/*py | flake8 --diff
  • Fully documented

@djhoese djhoese added the bug label Aug 23, 2024
@djhoese djhoese requested a review from mraspaud August 23, 2024 01:58
@djhoese djhoese self-assigned this Aug 23, 2024
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.97%. Comparing base (5f69bd8) to head (0a47fd3).
Report is 66 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #614   +/-   ##
=======================================
  Coverage   93.97%   93.97%           
=======================================
  Files          86       86           
  Lines       13811    13819    +8     
=======================================
+ Hits        12979    12987    +8     
  Misses        832      832           
Flag Coverage Δ
unittests 93.97% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@djhoese
Copy link
Member Author

djhoese commented Aug 23, 2024

Hm pre-commit on my local machine is behaving differently than pre-commit.ci.

Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

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

Lgtm, thanks for updating the PR template along the way.

@mraspaud mraspaud merged commit af0d4cc into pytroll:main Aug 24, 2024
26 checks passed
@djhoese djhoese deleted the bugfix-np210-compat branch August 28, 2024 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants