Skip to content

Commit

Permalink
Figure.savefig: Support uppercase file extensions (e.g., PNG, PDF) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Sep 22, 2023
1 parent 90de49b commit 6c933b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pygmt/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def savefig(

fname = Path(fname)
prefix, suffix = fname.with_suffix("").as_posix(), fname.suffix
ext = suffix[1:] # Remove the .
ext = suffix[1:].lower() # Remove the . and normalize to lowercase
# alias jpeg to jpg
if ext == "jpeg":
ext = "jpg"
Expand Down
8 changes: 5 additions & 3 deletions pygmt/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ def test_figure_savefig_exists():
fig = Figure()
fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af")
prefix = "test_figure_savefig_exists"
for fmt in "png pdf jpg jpeg bmp eps tif".split():
for fmt in "png pdf jpg jpeg bmp eps tif PNG JPG JPEG Png".split():
fname = ".".join([prefix, fmt])
fig.savefig(fname)
assert os.path.exists(fname)
os.remove(fname)

fname = Path(fname)
assert fname.exists()
fname.unlink()


def test_figure_savefig_directory_nonexists():
Expand Down

0 comments on commit 6c933b2

Please sign in to comment.