@@ -546,7 +546,7 @@ def __call__(self, x, pos=None):
546546 sign = np .sign (x )
547547 # only label the decades
548548 fx = math .log (abs (x ))/ math .log (b )
549- isDecade = self . is_decade (fx )
549+ isDecade = is_decade (fx )
550550 if not isDecade and self .labelOnlyBase : s = ''
551551 elif x > 10000 : s = '%1.0e' % x
552552 elif x < 1 : s = '%1.0e' % x
@@ -567,15 +567,6 @@ def format_data_short(self,value):
567567 'return a short formatted string representation of a number'
568568 return '%-12g' % value
569569
570- def is_decade (self , x ):
571- n = self .nearest_long (x )
572- return abs (x - n )< 1e-10
573-
574- def nearest_long (self , x ):
575- if x == 0 : return 0L
576- elif x > 0 : return long (x + 0.5 )
577- else : return long (x - 0.5 )
578-
579570 def pprint_val (self , x , d ):
580571 #if the number is not too big and it's an int, format it as an
581572 #int
@@ -617,7 +608,7 @@ def __call__(self, x, pos=None):
617608 sign = np .sign (x )
618609 # only label the decades
619610 fx = math .log (abs (x ))/ math .log (b )
620- isDecade = self . is_decade (fx )
611+ isDecade = is_decade (fx )
621612 if not isDecade and self .labelOnlyBase : s = ''
622613 #if 0: pass
623614 elif fx > 10000 : s = '%1.0e' % fx
@@ -644,7 +635,7 @@ def __call__(self, x, pos=None):
644635 return '$0$'
645636 sign = np .sign (x )
646637 fx = math .log (abs (x ))/ math .log (b )
647- isDecade = self . is_decade (fx )
638+ isDecade = is_decade (fx )
648639
649640 usetex = rcParams ['text.usetex' ]
650641
@@ -661,10 +652,10 @@ def __call__(self, x, pos=None):
661652 s = '$\mathdefault{%s%d^{%.2f}}$' % (sign_string , b , fx )
662653 else :
663654 if usetex :
664- s = r'$%s%d^{%d}$' % (sign_string , b , self . nearest_long (fx ))
655+ s = r'$%s%d^{%d}$' % (sign_string , b , nearest_long (fx ))
665656 else :
666657 s = r'$\mathdefault{%s%d^{%d}}$' % (sign_string , b ,
667- self . nearest_long (fx ))
658+ nearest_long (fx ))
668659
669660 return s
670661
@@ -1190,11 +1181,16 @@ def decade_up(x, base=10):
11901181 lx = math .ceil (math .log (x )/ math .log (base ))
11911182 return base ** lx
11921183
1193- def is_decade (x ,base = 10 ):
1184+ def nearest_long (x ):
1185+ if x == 0 : return 0L
1186+ elif x > 0 : return long (x + 0.5 )
1187+ else : return long (x - 0.5 )
1188+
1189+ def is_decade (x , base = 10 ):
11941190 if x == 0.0 :
11951191 return True
11961192 lx = math .log (x )/ math .log (base )
1197- return lx == int (lx )
1193+ return abs ( lx - nearest_long (lx )) < 1e-10
11981194
11991195class LogLocator (Locator ):
12001196 """
@@ -1212,7 +1208,7 @@ def __init__(self, base=10.0, subs=[1.0], numdecs=4):
12121208
12131209 def base (self ,base ):
12141210 """
1215- set the base of the log scaling (major tick every base**i, i interger )
1211+ set the base of the log scaling (major tick every base**i, i integer )
12161212 """
12171213 self ._base = base + 0.0
12181214
0 commit comments