-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Update Colorizer/ColorizingArtist to work with MultiNorm #30511
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
base: main
Are you sure you want to change the base?
Conversation
77bc51a
to
9044189
Compare
lib/matplotlib/tests/test_colors.py
Outdated
data = [[0, 0], [1, 1]] | ||
mdata = mcolorizer._ensure_multivariate_data(data, 2) |
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 is 2x2, which makes it unclear which dimension you are checking or if it's checking the right one. Same for all below. Better not to be square.
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.
👍 changed to data = [[0, 0, 0], [1, 1, 1]]
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.
What about the ones below?
9b9aaf3
to
525314e
Compare
Thank you for the feedback @QuLogic and apologies for my sloppy mistakes :) |
improved testing for colorizer+multinorm Apply suggestions from code review Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com> updates based on feedback from @QuLogic
525314e
to
23fb63c
Compare
|
||
return cm.colormaps[cmap_name] |
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.
Still can't run after the raise
.
if isinstance(cmap, types): | ||
return cmap | ||
|
||
cmap_name = cmap if cmap is not None else mpl.rcParams["image.cmap"] |
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.
That's mpl._val_or_rc
.
lib/matplotlib/tests/test_colors.py
Outdated
data = [[0, 0], [1, 1]] | ||
mdata = mcolorizer._ensure_multivariate_data(data, 2) |
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.
What about the ones below?
if not in_init and self.norm.n_components != cmap_obj.n_variates: | ||
raise ValueError(f"The colormap {cmap} does not support " | ||
f"{self.norm.n_components} variates as required by " | ||
f"the {type(self.norm)} on this Colorizer") |
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.
Block is over indented.
dt = np.dtype('float64, float64') | ||
else: | ||
dt = np.dtype('float32, float32') | ||
reconstructed = np.ma.frombuffer(data.data, dtype=dt).reshape(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.
Can you use a view to get this, instead of poking at the internal data buffer?
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.
Good point, the following appears to work for regular arrays, but nor masked arrays
reconstructed = data.view(dt)
I'll see if I can get a solution with view working for masked arrays as well
This PR continues the work of #28658 and #28454, #29876, aiming to close #14168. (Feature request: Bivariate colormapping)
This PR allows Colorizer and ColorizingArtist to work with
MultiNorm
andBivarColormap
andMultivarColormap
i.e. this PR will allow:
Features not included in this PR:
axes.imshow(...)
,axes.pcolor(...), and
axes.pcolormesh(...)`PR checklist