Skip to content

Commit f0758a1

Browse files
committed
Remove incompatibility with mpl v3.x
In mpl v3.x, cbook.is_scalar has been removed. It is used in only one place in basemap, and in that location it is not actually doing anything useful. I made a small reorganization and cleanup in that location in the interp function to fix another bug in which masked locations were being inadvertently unmasked without being filled with the mask value specified in the kwarg.
1 parent d588a67 commit f0758a1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/mpl_toolkits/basemap/__init__.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""
1515
from distutils.version import LooseVersion
1616
from matplotlib import __version__ as _matplotlib_version
17-
from matplotlib.cbook import is_scalar, dedent
17+
from matplotlib.cbook import dedent
1818
# check to make sure matplotlib is not too old.
1919
_matplotlib_version = LooseVersion(_matplotlib_version)
2020
_mpl_required_version = LooseVersion('0.98')
@@ -4984,12 +4984,11 @@ def interp(datain,xin,yin,xout,yout,checkbounds=False,masked=False,order=1):
49844984
dataout = map_coordinates(datain,coords,order=3,mode='nearest')
49854985
else:
49864986
raise ValueError('order keyword must be 0, 1 or 3')
4987-
if masked and isinstance(masked,bool):
4988-
dataout = ma.masked_array(dataout)
4987+
if masked:
49894988
newmask = ma.mask_or(ma.getmask(dataout), xymask)
4990-
dataout = ma.masked_array(dataout,mask=newmask)
4991-
elif masked and is_scalar(masked):
4992-
dataout = np.where(xymask,masked,dataout)
4989+
dataout = ma.masked_array(dataout, mask=newmask)
4990+
if not isinstance(masked, bool):
4991+
dataout = dataout.filled(masked)
49934992
return dataout
49944993

49954994
def shiftgrid(lon0,datain,lonsin,start=True,cyclic=360.0):

0 commit comments

Comments
 (0)