Skip to content

Commit

Permalink
FIX: if regrid shape is passed, we should respect it and not use fast…
Browse files Browse the repository at this point in the history
…-path
  • Loading branch information
greglucas committed Jul 11, 2024
1 parent ca2832e commit 4e19b50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/cartopy/mpl/geoaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,8 @@ def imshow(self, img, *args, **kwargs):
y0 - eps <= extent[3] <= y1 + eps))

if (transform is None or transform == self.transData or
same_projection and inside_bounds):
same_projection and inside_bounds and
kwargs.get("regrid_shape", None) is None):
result = super().imshow(img, *args, **kwargs)
else:
extent = kwargs.pop('extent', None)
Expand Down
11 changes: 11 additions & 0 deletions lib/cartopy/tests/mpl/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ def test_imshow_wrapping():
assert ax.get_xlim() == (-180, 180)


def test_imshow_arguments():
"""Smoke test for imshow argument passing in the fast-path"""
ax = plt.axes(projection=ccrs.PlateCarree())
# Set the regrid_shape parameter to ensure it isn't passed to Axes.imshow()
# in the fast-path call to super()
ax.imshow(np.random.random((10, 10)), transform=ccrs.PlateCarree(),
extent=(-180, 180, -90, 90), regrid_shape=500)

assert ax.get_xlim() == (-180, 180)


def test_imshow_rgba():
# tests that the alpha of a RGBA array passed to imshow is set to 0
# instead of masked
Expand Down

0 comments on commit 4e19b50

Please sign in to comment.