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

Numpy 1.6 fixes #3661

Merged
merged 3 commits into from Oct 17, 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
27 changes: 18 additions & 9 deletions lib/matplotlib/tests/test_colors.py
Expand Up @@ -237,13 +237,14 @@ def gray_from_float_rgba():
def test_light_source_topo_surface():
"""Shades a DEM using different v.e.'s and blend modes."""
fname = cbook.get_sample_data('jacksboro_fault_dem.npz', asfileobj=False)
with np.load(fname) as dem:
elev = dem['elevation']
# Get the true cellsize in meters for accurate vertical exaggeration
# Convert from decimal degrees to meters
dx, dy = dem['dx'], dem['dy']
dx = 111320.0 * dx * np.cos(dem['ymin'])
dy = 111320.0 * dy
dem = np.load(fname)
elev = dem['elevation']
# Get the true cellsize in meters for accurate vertical exaggeration
# Convert from decimal degrees to meters
dx, dy = dem['dx'], dem['dy']
dx = 111320.0 * dx * np.cos(dem['ymin'])
dy = 111320.0 * dy
dem.close()

ls = mcolors.LightSource(315, 45)
cmap = cm.gist_earth
Expand Down Expand Up @@ -307,7 +308,8 @@ def test_light_source_shading_default():
assert_array_almost_equal(rgb, expect, decimal=2)


@knownfailureif(V(np.__version__) >= V('1.9.0'))
@knownfailureif(V(np.__version__) >= V('1.9.0') or
V(np.__version__) < V('1.7.0'))
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 Down Expand Up @@ -371,7 +373,14 @@ def alternative_hillshade(azimuth, elev, z):
dy = -dy
dz = np.ones_like(dy)
normals = np.dstack([dx, dy, dz])
normals /= np.linalg.norm(normals, axis=2)[..., None]
dividers = np.zeros_like(z)[..., None]
for i, mat in enumerate(normals):
for j, vec in enumerate(mat):
dividers[i, j, 0] = np.linalg.norm(vec)
normals /= dividers
# once we drop support for numpy 1.7.x the above can be written as
# normals /= np.linalg.norm(normals, axis=2)[..., None]
# aviding the double loop.

intensity = np.tensordot(normals, illum, axes=(2, 0))
intensity -= intensity.min()
Expand Down