8000 Fix test on Python 3. Fixes #2080 · matplotlib/matplotlib@f966e4a · GitHub
[go: up one dir, main page]

Skip to content

Commit f966e4a

Browse files
committed
Fix test on Python 3. Fixes #2080
1 parent 026cc47 commit f966e4a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/tests/test_colors.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_cmap_and_norm_from_levels_and_colors2():
122122
clr = mcolors.colorConverter.to_rgba_array(colors)
123123
bad = (0.1, 0.1, 0.1, 0.1)
124124
no_color = (0.0, 0.0, 0.0, 0.0)
125-
masked_value = np.inf
125+
masked_value = 'masked_value'
126126

127127
# Define the test values which are of interest.
128128
# Note: levels are lev[i] <= v < lev[i+1]
@@ -163,10 +163,12 @@ def test_cmap_and_norm_from_levels_and_colors2():
163163
cmap, norm = mcolors.from_levels_and_colors(levels, colors[0:i1],
164164
extend=extend)
165165
cmap.set_bad(bad)
166-
for d_val, expected_color in sorted(cases.items()):
166+
for d_val, expected_color in cases.items():
167167
if d_val == masked_value:
168-
d_val = np.ma.array(1, mask=True)
169-
assert_array_equal(expected_color, cmap(norm([d_val]))[0],
168+
d_val = np.ma.array([1], mask=True)
169+
else:
170+
d_val = [d_val]
171+
assert_array_equal(expected_color, cmap(norm(d_val))[0],
170172
'Wih extend={0!r} and data '
171173
'value={1!r}'.format(extend, d_val))
172174

0 commit comments

Comments
 (0)
0