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 stretching integer data #153

Merged
merged 4 commits into from Nov 24, 2023
Merged

Conversation

pnuu
Copy link
Member

@pnuu pnuu commented Nov 24, 2023

This PR fixes stretching of linear integer data. The bug was introduced in #150 due to lack of testing.

  • Closes Linear stretch of uint8 data gives unexpected results #152 (remove if there is no corresponding issue, which should only be the case for minor changes)
  • Tests added (for all bug fixes or enhancements)
  • Tests passed (for all non-documentation changes)
  • Passes git diff origin/master **/*py | flake8 --diff (remove if you did not edit any Python files)
  • Fully documented (remove if this change should not be visible to users, e.g., if it is an internal clean-up, or if this is part of a larger project that will be documented later)

@pnuu pnuu added the bug label Nov 24, 2023
@pnuu pnuu self-assigned this Nov 24, 2023
@coveralls
Copy link

coveralls commented Nov 24, 2023

Coverage Status

coverage: 91.74% (+0.03%) from 91.713%
when pulling 034d659 on pnuu:bugfix-uint8-stretch
into dd16cdf on pytroll:main.

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.

Thanks for the fix and the test! I'm wondering if we should handle int (int32) differently, see inline comment.

Comment on lines 1100 to 1101
if np.issubdtype(dtype, np.integer):
dtype = np.dtype(np.float32)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be float64 if the input type is int32? the mantissa in float32 in 24bits, so it can't represent the full spectrum of values from int32...

Copy link
Member Author

Choose a reason for hiding this comment

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

The handling is adjusted in d35a5ac

Copy link
Member Author

Choose a reason for hiding this comment

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

And fixed in 034d659 . The previous attempt entered the wrong branch.

Copy link

codecov bot commented Nov 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (dd16cdf) 91.48% compared to head (034d659) 91.50%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #153      +/-   ##
==========================================
+ Coverage   91.48%   91.50%   +0.02%     
==========================================
  Files          12       12              
  Lines        3956     3969      +13     
==========================================
+ Hits         3619     3632      +13     
  Misses        337      337              
Flag Coverage Δ
unittests 91.50% <100.00%> (+0.02%) ⬆️

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.

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!

@mraspaud mraspaud merged commit 5b9227b into pytroll:main Nov 24, 2023
25 checks passed
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.

Linear stretch of uint8 data gives unexpected results
3 participants