@@ -457,7 +457,7 @@ def makeMappingArray(N, data, gamma=1.0):
457457 except :
458458 raise TypeError ("data must be convertable to an array" )
459459 shape = adata .shape
460- if len (shape ) != 2 and shape [1 ] != 3 :
460+ if len (shape ) != 2 or shape [1 ] != 3 :
461461 raise ValueError ("data must be nx3 format" )
462462
463463 x = adata [:, 0 ]
@@ -476,13 +476,12 @@ def makeMappingArray(N, data, gamma=1.0):
476476 xind = (N - 1 ) * np .linspace (0 , 1 , N ) ** gamma
477477 ind = np .searchsorted (x , xind )[1 :- 1 ]
478478
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 ]
481481 lut [0 ] = y1 [0 ]
482482 lut [- 1 ] = y0 [- 1 ]
483483 # 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 )
486485
487486
488487class Colormap (object ):
@@ -1196,7 +1195,7 @@ def inverse(self, value):
11961195
11971196 if cbook .iterable (value ):
11981197 val = ma .asarray (value )
1199- return ma .power (value , 1. / gamma ) * (vmax - vmin ) + vmin
1198+ return ma .power (val , 1. / gamma ) * (vmax - vmin ) + vmin
12001199 else :
12011200 return pow (value , 1. / gamma ) * (vmax - vmin ) + vmin
12021201
@@ -1551,8 +1550,7 @@ def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.):
15511550 aspect = np .arctan2 (- dy , - dx )
15521551 slope = 0.5 * np .pi - np .arctan (np .hypot (dx , dy ))
15531552 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 ))
15561554
15571555 # Apply contrast stretch
15581556 imin , imax = intensity .min (), intensity .max ()
0 commit comments