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
colors: ensure masked array data is an ndarray #6622
Conversation
This fixes compatibility for imshow plots with array data that is a unit-aware ndarray subclass, for example data frmo yt.units or astropy.units.
Hmm... that failure on travis is worrying. Let me see if I can reproduce it... |
Can't reproduce that failure locally... |
Travis failures are transient and non related |
Looks OK to me, but I suggest adding a brief comment so that someone doesn't look at it a year from now and "optimize" it away, thinking it is superfluous. |
Still not have tagged a v1.5.2, should probably backport this? |
If you can backport this for 1.5.2, that would be excellent :) |
FIX: ensure masked array data is an ndarray
backported to 1.5.x as 8d9357e |
Backported as it fixes a major Yt headache |
This fixes compatibility for imshow plots with array data that is a unit-aware ndarray subclass, for example data from yt.units or astropy.units.
Take for example the following script:
This produces the following traceback right now: https://gist.github.com/ngoldbaum/27effb41173859132fed08a0ad5485ee
This is not isolated to yt's units - if one tries the same thing with astropy's units the same issue arises. Pint does not have this issue because Pint's
Quantity
class is not an ndarray subclass, so when it is converted to a masked array inmatplotlib.image
, the units are stripped.This function seems to expect
result.data
to be an instance of the base ndarray class. This patch just enforces that expectation explicitly.