Skip to content

Commit

Permalink
Fix error checking colormap in geoviewer.py (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
adehecq authored Mar 13, 2024
1 parent cc5f625 commit 1b26455
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bin/geoviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,16 @@ def main(test_args: Sequence[str] = None) -> None:
vmax = None

# color map
# Get the list of existing color maps, including reversed maps
mpl_cmap_list = list(plt.cm.datad.keys())
mpl_cmap_list.extend([cmap + "_r" for cmap in mpl_cmap_list])

if args.cmap == "default":
cmap = plt.rcParams["image.cmap"]
elif args.cmap in plt.cm.datad.keys():
elif args.cmap in mpl_cmap_list:
cmap = args.cmap
else:
raise ValueError("Wrong cmap, must be in: {}".format(",".join(str(elem) for elem in plt.cm.datad.keys())))
raise ValueError("Wrong cmap, must be in: {}".format(",".join(str(elem) for elem in mpl_cmap_list)))

# Figsize
if args.figsize == "default":
Expand Down
1 change: 1 addition & 0 deletions tests/test_geoviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
(
(),
("-cmap", "Reds"),
("-cmap", "Reds_r"),
("-vmin", "-10", "-vmax", "10"),
("-vmin", "5%", "-vmax", "95%"),
("-band", "1"),
Expand Down

0 comments on commit 1b26455

Please sign in to comment.