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
Handle ImageNormalize cases when vmin >= vmax #15622
Conversation
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
ping @astrofrog |
Can you please rebase so I can see if #15837 really works? Thanks! |
b4523ee
to
4db4eb9
Compare
Rebased |
def test_vmin_vmax_equal(self): | ||
norm = ImageNormalize(vmin=2.0, vmax=2.0) | ||
data = np.arange(10) - 5.0 | ||
assert_equal(norm(data), np.zeros(data.shape)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would do smart broadcasting (I think).
assert_equal(norm(data), np.zeros(data.shape)) | |
assert_array_equal(norm(data), 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a small nitpick on test comparison. I'll leave it to you if you want to pursue or not. Feel free to merge when you are ready. Thanks!
4db4eb9
to
975355e
Compare
Description
With this PR, if
vmin == vmax
, theImageNormalize
class now maps the inputdata to 0. That is what the matplotlib
Normalize
class does. Currently a divide-by-zeroRuntimeWarning
is issued and the output data are (+/-) np.inf.Also if
vmin > vmax
, theImageNormalize
class now raises aValueError
instead of returning invalid results. This also matches the matplotlibNormalize
behavior.