Skip to content

Commit

Permalink
Protect against norm being set to None
Browse files Browse the repository at this point in the history
  • Loading branch information
ayshih committed Oct 26, 2023
1 parent de94545 commit 87c7393
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/7261.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug with :meth:`sunpy.map.GenericMap.plot` where setting ``norm`` to ``None`` would result in an error.
2 changes: 1 addition & 1 deletion sunpy/map/mapbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,7 @@ def plot(self, annotate=True, axes=None, title=True, autoalign=False,
msg = ('Cannot manually specify {0}, as the norm '
'already has {0} set. To prevent this error set {0} on '
'`m.plot_settings["norm"]` or the norm passed to `m.plot`.')
if 'norm' in imshow_args:
if imshow_args.get('norm', None) is not None:
norm = imshow_args['norm']
if 'vmin' in imshow_args:
if norm.vmin is not None:
Expand Down
6 changes: 6 additions & 0 deletions sunpy/map/tests/test_mapbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,12 @@ def test_as_mpl_axes_aia171(aia171_test_map):
assert all([ct1 == ct2 for ct1, ct2 in zip(ax.wcs.wcs.ctype, aia171_test_map.wcs.wcs.ctype)])


def test_plot_with_norm_none(aia171_test_map):
# Confirm that norm == None does not raise an error, see https://github.com/sunpy/sunpy/pull/7261
ax = plt.subplot(projection=aia171_test_map)
aia171_test_map.plot(axes=ax, norm=None, vmin=0, vmax=0)


def test_validate_meta(generic_map):
"""Check to see if_validate_meta displays an appropriate error"""
with pytest.warns(SunpyMetadataWarning) as w:
Expand Down

0 comments on commit 87c7393

Please sign in to comment.