Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions lib/mpl_toolkits/basemap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3901,6 +3901,12 @@ def drawlsmask(self,land_color="0.8",ocean_color="w",lsmask=None,
# look for axes instance (as keyword, an instance variable
# or from plt.gca().
ax = kwargs.pop('ax', None) or self._check_ax()
# Clear saved lsmask is new lsmask is passed
if lsmask is not None or lsmask_lons is not None \
or lsmask_lats is not None:
# Make sure passed lsmask is not the same as cached mask
if lsmask != self.lsmask:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use equality. Use is not instead when comparing objects.
Also, slight typo in the comments above "lsmask is new" --> "lsmask if new"

self.lsmask = None
# if lsmask,lsmask_lons,lsmask_lats keywords not given,
# read default land-sea mask in from file.
if lsmask is None or lsmask_lons is None or lsmask_lats is None:
Expand All @@ -3910,28 +3916,28 @@ def drawlsmask(self,land_color="0.8",ocean_color="w",lsmask=None,
# read in land/sea mask.
lsmask_lons, lsmask_lats, lsmask =\
_readlsmask(lakes=lakes,resolution=resolution,grid=grid)
# instance variable lsmask is set on first invocation,
# it contains the land-sea mask interpolated to the native
# projection grid. Further calls to drawlsmask will not
# redo the interpolation (unless a new land-sea mask is passed
# in via the lsmask, lsmask_lons, lsmask_lats keywords).

# is it a cylindrical projection whose limits lie
# outside the limits of the image?
cylproj = self.projection in _cylproj and \
(self.urcrnrlon > lsmask_lons[-1] or \
self.llcrnrlon < lsmask_lons[0])
if cylproj:
# stack grids side-by-side (in longitiudinal direction), so
# any range of longitudes may be plotted on a world map.
# in versions of NumPy later than 1.10.0, concatenate will
# not stack these arrays as expected. If axis 1 is outside
# the dimensions of the array, concatenate will now raise
# an IndexError. Using hstack instead.
lsmask_lons = \
np.hstack((lsmask_lons,lsmask_lons[1:] + 360))
lsmask = \
np.hstack((lsmask,lsmask[:,1:]))
# instance variable lsmask is set on first invocation,
# it contains the land-sea mask interpolated to the native
# projection grid. Further calls to drawlsmask will not
# redo the interpolation (unless a new land-sea mask is passed
# in via the lsmask, lsmask_lons, lsmask_lats keywords).

# is it a cylindrical projection whose limits lie
# outside the limits of the image?
cylproj = self.projection in _cylproj and \
(self.urcrnrlon > lsmask_lons[-1] or \
self.llcrnrlon < lsmask_lons[0])
if cylproj:
# stack grids side-by-side (in longitiudinal direction), so
# any range of longitudes may be plotted on a world map.
# in versions of NumPy later than 1.10.0, concatenate will
# not stack these arrays as expected. If axis 1 is outside
# the dimensions of the array, concatenate will now raise
# an IndexError. Using hstack instead.
lsmask_lons = \
np.hstack((lsmask_lons,lsmask_lons[1:] + 360))
lsmask = \
np.hstack((lsmask,lsmask[:,1:]))
else:
if lakes: lsmask = np.where(lsmask==2,np.array(0,np.uint8),lsmask)

Expand Down