Skip to content

Commit 1b9e6a6

Browse files
committed
MNT: make the tests easier to read
1 parent eabdb7d commit 1b9e6a6

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

lib/matplotlib/cm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from matplotlib._cm_listed import cmaps as cmaps_listed
2828
from matplotlib.cbook import _warn_external
2929

30+
3031
def _reverser(f, x): # Deprecated, remove this at the same time as revcmap.
3132
return f(1 - x) # Toplevel helper for revcmap ensuring cmap picklability.
3233

@@ -173,6 +174,7 @@ class ScalarMappable:
173174
RGBA colors from the given colormap.
174175
175176
"""
177+
176178
def __init__(self, norm=None, cmap=None):
177179
"""
178180

lib/matplotlib/tests/test_cm.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@
22
import warnings
33
import pytest
44

5+
56
def test_double_register_cmap():
67
with pytest.raises(ValueError):
7-
mcm.register_cmap('viridis', mcm.get_cmap('viridis'))
8+
mcm.register_cmap("viridis", mcm.get_cmap("viridis"))
89

910

1011
def test_register_cmap():
11-
mcm.register_cmap('viridis'[::-1], mcm.get_cmap('viridis'))
12-
assert mcm.get_cmap('viridis'[::-1]) is mcm.get_cmap('viridis')
12+
target = "viridis"[::-1]
13+
mcm.register_cmap(target, mcm.get_cmap("viridis"))
14+
assert mcm.get_cmap(target) is mcm.get_cmap("viridis")
1315

1416
with pytest.warns(UserWarning):
15-
mcm.register_cmap('viridis'[::-1], mcm.get_cmap('viridis'))
16-
17+
mcm.register_cmap(target, mcm.get_cmap("viridis"))
1718

18-
mcm.unregister_cmap('viridis'[::-1])
19+
mcm.unregister_cmap(target)
1920
with pytest.raises(ValueError):
20-
mcm.get_cmap('viridis'[::-1])
21+
mcm.get_cmap(target)
2122
# test that second time is error free
22-
mcm.unregister_cmap('viridis'[::-1])
23+
mcm.unregister_cmap(target)
2324

2425

2526
def test_unregister_cmap():
2627
with pytest.raises(ValueError):
27-
mcm.unregister_cmap('viridis')
28+
mcm.unregister_cmap("viridis")

0 commit comments

Comments
 (0)