Skip to content

Commit

Permalink
Fix for issue #409 and #407 (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
adehecq authored Jan 16, 2024
1 parent 41dc58f commit 3e45720
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 2 additions & 7 deletions geoutils/raster/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@ def reproject(
(dst_transform == self.transform) or (dst_transform is None),
(dst_crs == self.crs) or (dst_crs is None),
(dst_size == self.shape[::-1]) or (dst_size is None),
np.all(dst_res == self.res) or (dst_res == self.res[0] == self.res[1]) or (dst_res is None),
np.all(np.array(dst_res) == self.res) or (dst_res is None),
]
):
if (dst_nodata == self.nodata) or (dst_nodata is None):
Expand Down Expand Up @@ -2514,12 +2514,7 @@ def show(

# Create axes
if ax is None:
# If no figure exists, get a new axis
if len(plt.get_fignums()) == 0:
ax0 = plt.gca()
# Otherwise, get first axis
else:
ax0 = plt.gcf().axes[0]
ax0 = plt.gca()
elif isinstance(ax, str) and ax.lower() == "new":
_, ax0 = plt.subplots()
elif isinstance(ax, matplotlib.axes.Axes):
Expand Down
17 changes: 17 additions & 0 deletions tests/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,23 @@ def test_show(self) -> None:
img_RGB = gu.Raster(self.landsat_rgb_path)

# Test default plot
img.show()
if DO_PLOT:
plt.show()
else:
plt.close()
assert True

# Test with new figure
plt.figure()
img.show()
if DO_PLOT:
plt.show()
else:
plt.close()
assert True

# Test with provided ax
ax = plt.subplot(111)
img.show(ax=ax, title="Simple plotting test")
if DO_PLOT:
Expand Down

0 comments on commit 3e45720

Please sign in to comment.