-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ENH: Adding callbacks to Norms for update signals #19553
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
A callback registry has been added to Normalize objects | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
`.colors.Normalize` objects now have a callback registry, ``callbacks``, | ||
that can be connected to by other objects to be notified when the norm is | ||
updated. The callback emits the key ``changed`` when the norm is modified. | ||
`.cm.ScalarMappable` is now a listener and will register a change | ||
when the norm's vmin, vmax or other attributes are changed. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1017,8 +1017,8 @@ def test_imshow_bool(): | |
def test_full_invalid(): | ||
fig, ax = plt.subplots() | ||
ax.imshow(np.full((10, 10), np.nan)) | ||
with pytest.warns(UserWarning): | ||
fig.canvas.draw() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this not warning anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous warning was: matplotlib/lib/matplotlib/image.py:442: UserWarning: Warning: converting a masked element to nan.
vmid = np.float64(self.norm.vmin) + dv / 2 If I print out the previous Note that the image doesn't change at all, just no warning about norm vmin/vmax anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fun second-order behavior change!
Previously if you did im = plt.imshow(np.full((10, 10), np.nan), vmin=np.ma.masked, vmax=np.ma.masked)
assert im.norm.vmin == 0
assert im.norm.vmax == 0 but if you did im = plt.imshow(np.full((10, 10), np.nan)
assert im.norm.vmin is np.ma.masked
assert im.norm.vmax is np.ma.masked ( I would argue that this is a bug, in the sense that explicitly passing the We also say that if vmin == vmax the result of This will lead to a subtle behavior change in the case where:
Previously the user would get all "bad" color, now they will get the "0" color. Given the other difference in behavior of explicitly passing vmin/vmax, the agreement with "if vmin/vmax match -> go to 0", this feeling like a very cornery corner case, and the results already being useless from a communications point of view, I think we can leave this as-is and do not need a further API change note. |
||
fig.canvas.draw() | ||
|
||
|
||
@pytest.mark.parametrize("fmt,counted", | ||
|
Uh oh!
There was an error while loading. Please reload this page.