Skip to content

Commit 2d54786

Browse files
author
Jeff Whitaker
committed
replace hasattr(arr,'mask') with numpy.ma.isMA
1 parent 68c63bf commit 2d54786

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,7 +2835,7 @@ def pcolor(self,x,y,data,tri=False,**kwargs):
28352835
raise ImportError(msg)
28362836
# for unstructured grids, toss out points outside
28372837
# projection limb (don't use those points in triangulation).
2838-
if hasattr(data,'mask'):
2838+
if ma.isMA(data):
28392839
data = data.filled(fill_value=1.e30)
28402840
masked=True
28412841
else:
@@ -2925,7 +2925,7 @@ def contour(self,x,y,data,*args,**kwargs):
29252925
raise ImportError(msg)
29262926
# for unstructured grids, toss out points outside
29272927
# projection limb (don't use those points in triangulation).
2928-
if hasattr(data,'mask'):
2928+
if ma.isMA(data):
29292929
data = data.filled(fill_value=1.e30)
29302930
masked=True
29312931
else:
@@ -3010,7 +3010,7 @@ def contourf(self,x,y,data,*args,**kwargs):
30103010
raise ImportError(msg)
30113011
# for unstructured grids, toss out points outside
30123012
# projection limb (don't use those points in triangulation).
3013-
if hasattr(data,'mask'):
3013+
if ma.isMA(data):
30143014
data = data.filled(fill_value=1.e30)
30153015
masked=True
30163016
else:
@@ -3955,11 +3955,11 @@ def shiftgrid(lon0,datain,lonsin,start=True,cyclic=360.0):
39553955
raise ValueError('lon0 outside of range of lonsin')
39563956
i0 = np.argmin(np.fabs(lonsin-lon0))
39573957
i0_shift = len(lonsin)-i0
3958-
if hasattr(datain,'mask'):
3958+
if ma.isMA(datain):
39593959
dataout = ma.zeros(datain.shape,datain.dtype)
39603960
else:
39613961
dataout = np.zeros(datain.shape,datain.dtype)
3962-
if hasattr(lonsin,'mask'):
3962+
if ma.isMA(lonsin):
39633963
lonsout = ma.zeros(lonsin.shape,lonsin.dtype)
39643964
else:
39653965
lonsout = np.zeros(lonsin.shape,lonsin.dtype)
@@ -3982,13 +3982,13 @@ def addcyclic(arrin,lonsin):
39823982
"""
39833983
nlats = arrin.shape[0]
39843984
nlons = arrin.shape[1]
3985-
if hasattr(arrin,'mask'):
3985+
if ma.isMA(arrin):
39863986
arrout = ma.zeros((nlats,nlons+1),arrin.dtype)
39873987
else:
39883988
arrout = np.zeros((nlats,nlons+1),arrin.dtype)
39893989
arrout[:,0:nlons] = arrin[:,:]
39903990
arrout[:,nlons] = arrin[:,0]
3991-
if hasattr(lonsin,'mask'):
3991+
if ma.isMA(lonsin):
39923992
lonsout = ma.zeros(nlons+1,lonsin.dtype)
39933993
else:
39943994
lonsout = np.zeros(nlons+1,lonsin.dtype)

0 commit comments

Comments
 (0)