Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 244c1bb

Browse files
committed
Don't usea keyword to
git commit . -m Dont use axis keyword to np.linalg.norm. This was not added until numpy 1.8
1 parent 7b206eb commit 244c1bb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/matplotlib/tests/test_colors.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,14 @@ def alternative_hillshade(azimuth, elev, z):
373373
dy = -dy
374374
dz = np.ones_like(dy)
375375
normals = np.dstack([dx, dy, dz])
376-
normals /= np.linalg.norm(normals, axis=2)[..., None]
376+
dividers = np.zeros_like(z)[..., None]
377+
for i, mat in enumerate(normals):
378+
for j, vec in enumerate(mat):
379+
dividers[i, j, 0] = np.linalg.norm(vec)
380+
normals /= dividers
381+
# once we drop support for numpy 1.7.x the above can be written as
382+
# normals /= np.linalg.norm(normals, axis=2)[..., None]
383+
# aviding the double loop.
377384

378385
intensity = np.tensordot(normals, illum, axes=(2, 0))
379386
intensity -= intensity.min()

0 commit comments

Comments
 (0)