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

Skip to content

Commit 2209689

Browse files
committed
Minor speed improvement
svn path=/branches/transforms/; revision=4762
1 parent b76e234 commit 2209689

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/matplotlib/scale.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,10 @@ def __init__(self, thresh):
301301

302302
def transform(self, a):
303303
masked = ma.masked_where((a < -self.thresh) | (a > self.thresh), a)
304-
return ma.log(ma.tan(masked) + 1.0 / ma.cos(masked))
304+
if masked.mask.any():
305+
return ma.log(ma.abs(ma.tan(masked) + 1.0 / ma.cos(masked)))
306+
else:
307+
return npy.log(npy.abs(npy.tan(a) + 1.0 / npy.cos(a)))
305308

306309
def inverted(self):
307310
return MercatorLatitudeScale.InvertedMercatorLatitudeTransform()
@@ -346,6 +349,7 @@ def get_transform(self):
346349
def limit_range_for_scale(self, vmin, vmax, minpos):
347350
return max(vmin, -self.thresh), min(vmax, self.thresh)
348351

352+
349353
_scale_mapping = {
350354
'linear' : LinearScale,
351355
'log' : LogScale,

0 commit comments

Comments
 (0)