From b72b0f7440ccb759de15bff40eab3407cd77c21a Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Wed, 29 May 2013 14:27:16 +0100 Subject: [PATCH] Fixed failing test on python3. --- lib/matplotlib/tests/test_colors.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 900a373ddf09..c7b1f9e4acf5 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -122,6 +122,7 @@ def test_cmap_and_norm_from_levels_and_colors2(): clr = mcolors.colorConverter.to_rgba_array(colors) bad = (0.1, 0.1, 0.1, 0.1) no_color = (0.0, 0.0, 0.0, 0.0) + masked_value = 'masked value' # Define the test values which are of interest. # Note: levels are lev[i] <= v < lev[i+1] @@ -131,7 +132,7 @@ def test_cmap_and_norm_from_levels_and_colors2(): 2.25: clr[2], 3: clr[4], 3.5: clr[4], - np.ma.array(1, mask=True): bad}), + masked_value: bad}), ('min', -1, {-2: clr[0], -1: clr[1], @@ -139,7 +140,7 @@ def test_cmap_and_norm_from_levels_and_colors2(): 2.25: clr[2], 3: no_color, 3.5: no_color, - np.ma.array(1, mask=True): bad}), + masked_value: bad}), ('max', -1, {-2: no_color, -1: clr[0], @@ -147,7 +148,7 @@ def test_cmap_and_norm_from_levels_and_colors2(): 2.25: clr[1], 3: clr[3], 3.5: clr[3], - np.ma.array(1, mask=True): bad}), + masked_value: bad}), ('neither', -2, {-2: no_color, -1: clr[0], @@ -155,7 +156,7 @@ def test_cmap_and_norm_from_levels_and_colors2(): 2.25: clr[1], 3: no_color, 3.5: no_color, - np.ma.array(1, mask=True): bad}), + masked_value: bad}), ] for extend, i1, cases in tests: @@ -163,6 +164,8 @@ def test_cmap_and_norm_from_levels_and_colors2(): extend=extend) cmap.set_bad(bad) for d_val, expected_color in sorted(cases.items()): + if d_val == masked_value: + d_val = np.ma.array(1, mask=True) assert_array_equal(expected_color, cmap(norm([d_val]))[0], 'Wih extend={0!r} and data ' 'value={1!r}'.format(extend, d_val))