There is a test in astropy that started breaking when using matplotlib + numpy 1.24.0.dev0+896.g5ecaf36cd . Same error using stable matplotlib and matplotlib from the nightly wheel.
This seems to be due to a change in how masked arrays work in numpy. Under some condition we are getting masks which are a single bool rather than an array of bools.
-> 5281 for idx0, idx1 in cbook.contiguous_regions(where):
which also fails on older versions of numpy (which seems both reasonable and correct).
That is far as made it debugging this. Not sure if this is a regression upstream in numpy we should report or if this is intentional change we need to adapt to.
This bisects to numpy/numpy@44c8da9, which coincidentally fixes numpy/numpy#19332 which is a bug I reported. np.ma.masked_invalid now mirrors np.ma.masked_where as documented.
The np.ma.masked_invalid call is a couple lines earlier, but strangely, we don't use copy=False. I guess this is just another inconsistency between the two.
Activity
tacaswell commented on Oct 7, 2022
This seems to be due to a change in how masked arrays work in numpy. Under some condition we are getting masks which are a single bool rather than an array of bools.
Looking at %debug you can see
ipdb> p functools.reduce(np.logical_or, map(np.ma.getmask, [ind, dep1, dep2])) False ipdb> ind masked_array(data=[1, 3], mask=False, fill_value=999999) ipdb> dep1 masked_array(data=[3, 5], mask=False, fill_value=999999) ipdb> dep2 masked_array(data=[3.05, 3.01], mask=False, fill_value=1e+20)which means that we pass a bool into
which also fails on older versions of numpy (which seems both reasonable and correct).
That is far as made it debugging this. Not sure if this is a regression upstream in numpy we should report or if this is intentional change we need to adapt to.
@melissawm as our local numpy dev.
QuLogic commented on Oct 7, 2022
This bisects to numpy/numpy@44c8da9, which coincidentally fixes numpy/numpy#19332 which is a bug I reported. np.ma.masked_invalid now mirrors np.ma.masked_where as documented.
The np.ma.masked_invalid call is a couple lines earlier, but strangely, we don't use copy=False. I guess this is just another inconsistency between the two.
QuLogic commented on Oct 7, 2022
Something like this might work?
QuLogic commented on Oct 7, 2022
Or actually, since we definitely want an array here, this is probably better:
Fix mask lookup in fill_between for NumPy 1.24+
pllim commented on Oct 7, 2022
Thanks for the quick fix! 🙇♀️
DOC: Add 3D plots to plot_types gallery
Fix mask lookup in fill_between for NumPy 1.24+
Add Laura's edits to earthscope notebook