@@ -457,7 +457,7 @@ def makeMappingArray(N, data, gamma=1.0):
457
457
except :
458
458
raise TypeError ("data must be convertable to an array" )
459
459
shape = adata .shape
460
- if len (shape ) != 2 and shape [1 ] != 3 :
460
+ if len (shape ) != 2 or shape [1 ] != 3 :
461
461
raise ValueError ("data must be nx3 format" )
462
462
463
463
x = adata [:, 0 ]
@@ -476,13 +476,12 @@ def makeMappingArray(N, data, gamma=1.0):
476
476
xind = (N - 1 ) * np .linspace (0 , 1 , N ) ** gamma
477
477
ind = np .searchsorted (x , xind )[1 :- 1 ]
478
478
479
- lut [ 1 : - 1 ] = ((( xind [1 :- 1 ] - x [ind - 1 ]) / (x [ind ] - x [ind - 1 ])) *
480
- (y0 [ind ] - y1 [ind - 1 ]) + y1 [ind - 1 ])
479
+ distance = (xind [1 :- 1 ] - x [ind - 1 ]) / (x [ind ] - x [ind - 1 ])
480
+ lut [ 1 : - 1 ] = distance * (y0 [ind ] - y1 [ind - 1 ]) + y1 [ind - 1 ]
481
481
lut [0 ] = y1 [0 ]
482
482
lut [- 1 ] = y0 [- 1 ]
483
483
# ensure that the lut is confined to values between 0 and 1 by clipping it
484
- np .clip (lut , 0.0 , 1.0 )
485
- return lut
484
+ return np .clip (lut , 0.0 , 1.0 )
486
485
487
486
488
487
class Colormap (object ):
@@ -1196,7 +1195,7 @@ def inverse(self, value):
1196
1195
1197
1196
if cbook .iterable (value ):
1198
1197
val = ma .asarray (value )
1199
- return ma .power (value , 1. / gamma ) * (vmax - vmin ) + vmin
1198
+ return ma .power (val , 1. / gamma ) * (vmax - vmin ) + vmin
1200
1199
else :
1201
1200
return pow (value , 1. / gamma ) * (vmax - vmin ) + vmin
1202
1201
@@ -1551,8 +1550,7 @@ def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.):
1551
1550
aspect = np .arctan2 (- dy , - dx )
1552
1551
slope = 0.5 * np .pi - np .arctan (np .hypot (dx , dy ))
1553
1552
intensity = (np .sin (alt ) * np .sin (slope ) +
1554
- np .cos (alt ) * np .cos (slope ) *
1555
- np .cos (az - aspect ))
1553
+ np .cos (alt ) * np .cos (slope ) * np .cos (az - aspect ))
1556
1554
1557
1555
# Apply contrast stretch
1558
1556
imin , imax = intensity .min (), intensity .max ()
0 commit comments