Skip to content

Commit

Permalink
Fix bug with Raster.show #407. Update test accordingly.
Browse files Browse the repository at this point in the history
  • Loading branch information
adehecq committed Oct 20, 2023
1 parent a63b04c commit f991515
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 1 addition & 6 deletions geoutils/raster/raster.py
Original file line number Diff line number Diff line change
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
8 changes: 8 additions & 0 deletions tests/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,14 @@ 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 provided ax
ax = plt.subplot(111)
img.show(ax=ax, title="Simple plotting test")
if DO_PLOT:
Expand Down

0 comments on commit f991515

Please sign in to comment.