8000 Reenable shading tests for numpy 1.9.1 and later · matplotlib/matplotlib@ac54463 · GitHub
[go: up one dir, main page]

Skip to content

Commit ac54463

Browse files
committed
Reenable shading tests for numpy 1.9.1 and later
1 parent cf5b9a7 commit ac54463

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

lib/matplotlib/tests/test_colors.py

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ def test_light_source_topo_surface():
258258
ax.set(xticks=[], yticks=[])
259259

260260

261-
@knownfailureif(V(np.__version__) >= V('1.9.0'))
262261
def test_light_source_shading_default():
263262
"""Array comparison test for the default "hsv" blend mode. Ensure the
264263
default result doesn't change without warning."""
@@ -305,11 +304,19 @@ def test_light_source_shading_default():
305304
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
306305
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
307306
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00]]]).T
307+
if (V(np.__version__) == V('1.9.0')):
308+
# Numpy 1.9.0 uses a 2. order algorithm on the edges by default
309+
# This was changed back again in 1.9.1
310+
expect = expect[1:-1, 1:-1, :]
311+
rgb = rgb[1:-1, 1:-1, :]
312+
308313
assert_array_almost_equal(rgb, expect, decimal=2)
309314

310315

311-
@knownfailureif(V(np.__version__) >= V('1.9.0') or
312-
V(np.__version__) < V('1.7.0'))
316+
@knownfailureif(V(np.__version__) <= V('1.9.0'))
317+
# Numpy 1.9.1 fixed a bug in masked arrays which resulted in
318+
# additional elements being masked when calculating the gradient thus
319+
# the output is different with earlier numpy versions.
313320
def test_light_source_masked_shading():
314321
"""Array comparison test for a surface with a masked portion. Ensures that
315322
we don't wind up with "fringes" of odd colors around masked regions."""
@@ -323,32 +330,32 @@ def test_light_source_masked_shading():
323330
rgb = ls.shade(z, cmap)
324331

325332
# Result stored transposed and rounded for for more compact display...
326-
expect = np.array([[[1.00, 0.95, 0.96, 0.94, 0.86, 0.67, 0.40, 0.03],
327-
[0.95, 0.99, 1.00, 1.00, 1.00, 0.98, 0.67, 0.19],
328-
[0.96, 1.00, 1.00, 1.00, 1.00, 1.00, 0.78, 0.36],
329-
[0.94, 1.00, 1.00, 0.00, 0.00, 1.00, 0.55, 0.32],
330-
[0.86, 1.00, 1.00, 0.00, 0.00, 1.00, 0.27, 0.14],
331-
[0.67, 0.98, 1.00, 1.00, 1.00, 1.00, 0.07, 0.03],
332-
[0.40, 0.67, 0.78, 0.55, 0.27, 0.07, 0.00, 0.01],
333-
[0.03, 0.19, 0.36, 0.32, 0.14, 0.03, 0.01, 0.00]],
334-
335-
[[1.00, 0.93, 0.93, 0.88, 0.72, 0.50, 0.28, 0.03],
336-
[0.93, 0.97, 0.99, 0.96, 0.87, 0.70, 0.42, 0.11],
337-
[0.93, 0.99, 0.74, 0.78, 0.78, 0.74, 0.45, 0.20],
338-
[0.88, 0.96, 0.78, 0.00, 0.00, 0.78, 0.32, 0.16],
339-
[0.72, 0.87, 0.78, 0.00, 0.00, 0.78, 0.14, 0.06],
340-
[0.50, 0.70, 0.74, 0.78, 0.78, 0.74, 0.03, 0.01],
341-
[0.28, 0.42, 0.45, 0.32, 0.14, 0.03, 0.00, 0.00],
342-
[0.03, 0.11, 0.20, 0.16, 0.06, 0.01, 0.00, 0.00]],
343-
344-
[[1.00, 0.91, 0.91, 0.84, 0.64, 0.39, 0.21, 0.03],
345-
[0.91, 0.96, 0.98, 0.93, 0.77, 0.53, 0.27, 0.06],
346-
[0.91, 0.98, 0.47, 0.50, 0.50, 0.47, 0.25, 0.10],
347-
[0.84, 0.93, 0.50, 0.00, 0.00, 0.50, 0.13, 0.06],
348-
[0.64, 0.77, 0.50, 0.00, 0.00, 0.50, 0.03, 0.01],
349-
[0.39, 0.53, 0.47, 0.50, 0.50, 0.47, 0.00, 0.00],
350-
[0.21, 0.27, 0.25, 0.13, 0.03, 0.00, 0.00, 0.00],
351-
[0.03, 0.06, 0.10, 0.06, 0.01, 0.00, 0.00, 0.00]],
333+
expect = np.array([[[0.90, 0.88, 0.91, 0.91, 0.84, 0.64, 0.36, 0.00],
334+
[0.88, 0.96, 1.00, 1.00, 1.00, 0.97, 0.64, 0.18],
335+
[0.91, 1.00, 1.00, 1.00, 1.00, 1.00, 0.74, 0.34],
336+
[0.91, 1.00, 1.00, 0.00, 0.00, 1.00, 0.52, 0.30],
337+
[0.84, 1.00, 1.00, 0.00, 0.00, 1.00, 0.25, 0.13],
338+
[0.64, 0.97, 1.00, 1.00, 1.00, 0.23, 0.07, 0.03],
339+
[0.36, 0.64, 0.74, 0.52, 0.25, 0.07, 0.00, 0.01],
340+
[0.00, 0.18, 0.34, 0.30, 0.13, 0.03, 0.01, 0.00]],
341+
342+
[[0.90, 0.82, 0.85, 0.82, 0.68, 0.46, 0.24, 0.00],
343+
[0.82, 0.91, 0.95, 0.93, 0.85, 0.68, 0.39, 0.10],
344+
[0.85, 0.95, 1.00, 0.78, 0.78, 0.77, 0.42, 0.18],
345+
[0.82, 0.93, 0.78, 0.00, 0.00, 0.78, 0.30, 0.15],
346+
[0.68, 0.85, 0.78, 0.00, 0.00, 0.78, 0.13, 0.06],
347+
[0.46, 0.68, 0.77, 0.78, 0.78, 0.13, 0.03, 0.01],
348+
[0.24, 0.39, 0.42, 0.30, 0.13, 0.03, 0.00, 0.00],
349+
[0.00, 0.10, 0.18, 0.15, 0.06, 0.01, 0.00, 0.00]],
350+
351+
[[0.90, 0.79, 0.81, 0.76, 0.58, 0.35, 0.17, 0.00],
352+
[0.79, 0.88, 0.92, 0.88, 0.73, 0.50, 0.24, 0.05],
353+
[0.81, 0.92, 1.00, 0.50, 0.50, 0.53, 0.22, 0.09],
354+
[0.76, 0.88, 0.50, 0.00, 0.00, 0.50, 0.12, 0.05],
355+
[0.58, 0.73, 0.50, 0.00, 0.00, 0.50, 0.03, 0.01],
356+
[0.35, 0.50, 0.53, 0.50, 0.50, 0.02, 0.00, 0.00],
357+
[0.17, 0.24, 0.22, 0.12, 0.03, 0.00, 0.00, 0.00],
358+
[0.00, 0.05, 0.09, 0.05, 0.01, 0.00, 0.00, 0.00]],
352359

353360
[[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
354361
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
@@ -358,6 +365,7 @@ def test_light_source_masked_shading():
358365
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
359366
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
360367
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00]]]).T
368+
361369
assert_array_almost_equal(rgb, expect, decimal=2)
362370

363371

0 commit comments

Comments
 (0)
0