|
From: <md...@us...> - 2010-10-13 18:04:07
|
Revision: 8753
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8753&view=rev
Author: mdboom
Date: 2010-10-13 18:04:01 +0000 (Wed, 13 Oct 2010)
Log Message:
-----------
Merged revisions 8752 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v1_0_maint
........
r8752 | mdboom | 2010-10-13 14:01:59 -0400 (Wed, 13 Oct 2010) | 2 lines
Fix is_decade()
........
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/ticker.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /branches/v1_0_maint:1-8749 /trunk/matplotlib:1-7315
+ /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /branches/v1_0_maint:1-8752 /trunk/matplotlib:1-7315
Modified: trunk/matplotlib/lib/matplotlib/ticker.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/ticker.py 2010-10-13 18:01:59 UTC (rev 8752)
+++ trunk/matplotlib/lib/matplotlib/ticker.py 2010-10-13 18:04:01 UTC (rev 8753)
@@ -545,7 +545,7 @@
sign = np.sign(x)
# only label the decades
fx = math.log(abs(x))/math.log(b)
- isDecade = self.is_decade(fx)
+ isDecade = is_decade(fx)
if not isDecade and self.labelOnlyBase: s = ''
elif x>10000: s= '%1.0e'%x
elif x<1: s = '%1.0e'%x
@@ -566,15 +566,6 @@
'return a short formatted string representation of a number'
return '%-12g'%value
- def is_decade(self, x):
- n = self.nearest_long(x)
- return abs(x-n)<1e-10
-
- def nearest_long(self, x):
- if x == 0: return 0L
- elif x > 0: return long(x+0.5)
- else: return long(x-0.5)
-
def pprint_val(self, x, d):
#if the number is not too big and it's an int, format it as an
#int
@@ -616,7 +607,7 @@
sign = np.sign(x)
# only label the decades
fx = math.log(abs(x))/math.log(b)
- isDecade = self.is_decade(fx)
+ isDecade = is_decade(fx)
if not isDecade and self.labelOnlyBase: s = ''
#if 0: pass
elif fx>10000: s= '%1.0e'%fx
@@ -643,7 +634,7 @@
return '$0$'
sign = np.sign(x)
fx = math.log(abs(x))/math.log(b)
- isDecade = self.is_decade(fx)
+ isDecade = is_decade(fx)
usetex = rcParams['text.usetex']
@@ -660,10 +651,10 @@
s = '$\mathdefault{%s%d^{%.2f}}$'% (sign_string, b, fx)
else:
if usetex:
- s = r'$%s%d^{%d}$'% (sign_string, b, self.nearest_long(fx))
+ s = r'$%s%d^{%d}$'% (sign_string, b, nearest_long(fx))
else:
s = r'$\mathdefault{%s%d^{%d}}$'% (sign_string, b,
- self.nearest_long(fx))
+ nearest_long(fx))
return s
@@ -1189,11 +1180,16 @@
lx = np.ceil(np.log(x)/np.log(base))
return base**lx
-def is_decade(x,base=10):
+def nearest_long(x):
+ if x == 0: return 0L
+ elif x > 0: return long(x+0.5)
+ else: return long(x-0.5)
+
+def is_decade(x, base=10):
if x == 0.0:
return True
lx = np.log(x)/np.log(base)
- return lx==int(lx)
+ return abs(lx - nearest_long(lx)) < 1e-10
class LogLocator(Locator):
"""
@@ -1211,7 +1207,7 @@
def base(self,base):
"""
- set the base of the log scaling (major tick every base**i, i interger)
+ set the base of the log scaling (major tick every base**i, i integer)
"""
self._base=base+0.0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|