Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reenable shading tests for numpy 1.9.1 and later #3755

Merged
merged 2 commits into from Nov 5, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 38 additions & 29 deletions lib/matplotlib/tests/test_colors.py
Expand Up @@ -258,7 +258,6 @@ def test_light_source_topo_surface():
ax.set(xticks=[], yticks=[])


@knownfailureif(V(np.__version__) >= V('1.9.0'))
def test_light_source_shading_default():
"""Array comparison test for the default "hsv" blend mode. Ensure the
default result doesn't change without warning."""
Expand Down Expand Up @@ -305,11 +304,20 @@ def test_light_source_shading_default():
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00]]]).T
if (V(np.__version__) == V('1.9.0')):
# Numpy 1.9.0 uses a 2. order algorithm on the edges by default
# This was changed back again in 1.9.1
expect = expect[1:-1, 1:-1, :]
rgb = rgb[1:-1, 1:-1, :]

assert_array_almost_equal(rgb, expect, decimal=2)


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

# Result stored transposed and rounded for for more compact display...
expect = np.array([[[1.00, 0.95, 0.96, 0.94, 0.86, 0.67, 0.40, 0.03],
[0.95, 0.99, 1.00, 1.00, 1.00, 0.98, 0.67, 0.19],
[0.96, 1.00, 1.00, 1.00, 1.00, 1.00, 0.78, 0.36],
[0.94, 1.00, 1.00, 0.00, 0.00, 1.00, 0.55, 0.32],
[0.86, 1.00, 1.00, 0.00, 0.00, 1.00, 0.27, 0.14],
[0.67, 0.98, 1.00, 1.00, 1.00, 1.00, 0.07, 0.03],
[0.40, 0.67, 0.78, 0.55, 0.27, 0.07, 0.00, 0.01],
[0.03, 0.19, 0.36, 0.32, 0.14, 0.03, 0.01, 0.00]],

[[1.00, 0.93, 0.93, 0.88, 0.72, 0.50, 0.28, 0.03],
[0.93, 0.97, 0.99, 0.96, 0.87, 0.70, 0.42, 0.11],
[0.93, 0.99, 0.74, 0.78, 0.78, 0.74, 0.45, 0.20],
[0.88, 0.96, 0.78, 0.00, 0.00, 0.78, 0.32, 0.16],
[0.72, 0.87, 0.78, 0.00, 0.00, 0.78, 0.14, 0.06],
[0.50, 0.70, 0.74, 0.78, 0.78, 0.74, 0.03, 0.01],
[0.28, 0.42, 0.45, 0.32, 0.14, 0.03, 0.00, 0.00],
[0.03, 0.11, 0.20, 0.16, 0.06, 0.01, 0.00, 0.00]],

[[1.00, 0.91, 0.91, 0.84, 0.64, 0.39, 0.21, 0.03],
[0.91, 0.96, 0.98, 0.93, 0.77, 0.53, 0.27, 0.06],
[0.91, 0.98, 0.47, 0.50, 0.50, 0.47, 0.25, 0.10],
[0.84, 0.93, 0.50, 0.00, 0.00, 0.50, 0.13, 0.06],
[0.64, 0.77, 0.50, 0.00, 0.00, 0.50, 0.03, 0.01],
[0.39, 0.53, 0.47, 0.50, 0.50, 0.47, 0.00, 0.00],
[0.21, 0.27, 0.25, 0.13, 0.03, 0.00, 0.00, 0.00],
[0.03, 0.06, 0.10, 0.06, 0.01, 0.00, 0.00, 0.00]],
expect = np.array([[[0.90, 0.88, 0.91, 0.91, 0.84, 0.64, 0.36, 0.00],
[0.88, 0.96, 1.00, 1.00, 1.00, 0.97, 0.64, 0.18],
[0.91, 1.00, 1.00, 1.00, 1.00, 1.00, 0.74, 0.34],
[0.91, 1.00, 1.00, 0.00, 0.00, 1.00, 0.52, 0.30],
[0.84, 1.00, 1.00, 0.00, 0.00, 1.00, 0.25, 0.13],
[0.64, 0.97, 1.00, 1.00, 1.00, 0.23, 0.07, 0.03],
[0.36, 0.64, 0.74, 0.52, 0.25, 0.07, 0.00, 0.01],
[0.00, 0.18, 0.34, 0.30, 0.13, 0.03, 0.01, 0.00]],

[[0.90, 0.82, 0.85, 0.82, 0.68, 0.46, 0.24, 0.00],
[0.82, 0.91, 0.95, 0.93, 0.85, 0.68, 0.39, 0.10],
[0.85, 0.95, 1.00, 0.78, 0.78, 0.77, 0.42, 0.18],
[0.82, 0.93, 0.78, 0.00, 0.00, 0.78, 0.30, 0.15],
[0.68, 0.85, 0.78, 0.00, 0.00, 0.78, 0.13, 0.06],
[0.46, 0.68, 0.77, 0.78, 0.78, 0.13, 0.03, 0.01],
[0.24, 0.39, 0.42, 0.30, 0.13, 0.03, 0.00, 0.00],
[0.00, 0.10, 0.18, 0.15, 0.06, 0.01, 0.00, 0.00]],

[[0.90, 0.79, 0.81, 0.76, 0.58, 0.35, 0.17, 0.00],
[0.79, 0.88, 0.92, 0.88, 0.73, 0.50, 0.24, 0.05],
[0.81, 0.92, 1.00, 0.50, 0.50, 0.53, 0.22, 0.09],
[0.76, 0.88, 0.50, 0.00, 0.00, 0.50, 0.12, 0.05],
[0.58, 0.73, 0.50, 0.00, 0.00, 0.50, 0.03, 0.01],
[0.35, 0.50, 0.53, 0.50, 0.50, 0.02, 0.00, 0.00],
[0.17, 0.24, 0.22, 0.12, 0.03, 0.00, 0.00, 0.00],
[0.00, 0.05, 0.09, 0.05, 0.01, 0.00, 0.00, 0.00]],

[[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
Expand All @@ -358,6 +366,7 @@ def test_light_source_masked_shading():
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00],
[1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00]]]).T

assert_array_almost_equal(rgb, expect, decimal=2)


Expand Down