BUG: Fix weird behavior with mask and units (Fixes #8908)#9049
BUG: Fix weird behavior with mask and units (Fixes #8908)#9049dstansby merged 4 commits intomatplotlib:masterfrom
Conversation
| if hasattr(x, 'mask'): | ||
| return np.ma.asarray(x, float).filled(np.nan) | ||
| else: | ||
| return np.asarray(x, float) |
There was a problem hiding this comment.
The existing code was always going to a straight-up numpy array, and since that part of the behavior didn't seem to be causing any unit-related problems, it seemed best to be conservative and keep it as asarray.
|
Is there a way to test this without picking up a pint dependency? |
|
Looks like I already started a small pint knock-off in |
|
Added a test. Also rolled back changes to |
|
IMO, this is good to go. |
|
I went ahead and added the test I developed for #8910. The only outstanding question on that is whether the call to |
Refactor many places that check for masked arrays, and fill the masked values with nans, with a helper to accomplish that. In the helper, replace the isinstance check with a attribute check for 'mask'. This allows libraries, like pint, that wrap mask arrays to pass the check and be converted appropriately. Also fix one spot using atleast_1d with _check_1d.
This tests that unit libraries that wrap arrays, like pint, work properly. This adds an image test that checks current behavior, which seems to be fully correct.
|
Went ahead and added a new callback for the |
This adds a independent callback for units changes that both updates the data limits (relim) as well as the view limits (autoscale_view).
|
Fixed tests by making sure to only autoscale relevant axis. |
|
I suspect that this will make @TD22057 happy. |
Refactor many places that check for masked arrays, and fill the masked
values with nans, with a helper to accomplish that. In the helper,
replace the isinstance check with a attribute check for 'mask'. This
allows libraries, like pint, that wrap mask arrays to pass the check and
be converted appropriately.
Also fix one spot using
atleast_1dwith_check_1d.