|
From: <md...@us...> - 2010-10-12 19:13:15
|
Revision: 8749
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8749&view=rev
Author: mdboom
Date: 2010-10-12 19:13:09 +0000 (Tue, 12 Oct 2010)
Log Message:
-----------
Safer handling of the minimum positive value in log locators.
Modified Paths:
--------------
branches/v1_0_maint/lib/matplotlib/ticker.py
Modified: branches/v1_0_maint/lib/matplotlib/ticker.py
===================================================================
--- branches/v1_0_maint/lib/matplotlib/ticker.py 2010-10-12 17:23:36 UTC (rev 8748)
+++ branches/v1_0_maint/lib/matplotlib/ticker.py 2010-10-12 19:13:09 UTC (rev 8749)
@@ -1244,7 +1244,7 @@
if vmin <= 0.0:
vmin = self.axis.get_minpos()
- if vmin <= 0.0:
+ if vmin <= 0.0 or not np.isfinite(vmin):
raise ValueError(
"Data has no positive values, and therefore can not be log-scaled.")
@@ -1292,7 +1292,7 @@
minpos = self.axis.get_minpos()
- if minpos<=0:
+ if minpos<=0 or not np.isfinite(minpos):
raise ValueError(
"Data has no positive values, and therefore can not be log-scaled.")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-10-13 18:02:05
|
Revision: 8752
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8752&view=rev
Author: mdboom
Date: 2010-10-13 18:01:59 +0000 (Wed, 13 Oct 2010)
Log Message:
-----------
Fix is_decade()
Modified Paths:
--------------
branches/v1_0_maint/lib/matplotlib/ticker.py
Modified: branches/v1_0_maint/lib/matplotlib/ticker.py
===================================================================
--- branches/v1_0_maint/lib/matplotlib/ticker.py 2010-10-13 15:45:14 UTC (rev 8751)
+++ branches/v1_0_maint/lib/matplotlib/ticker.py 2010-10-13 18:01:59 UTC (rev 8752)
@@ -546,7 +546,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
@@ -567,15 +567,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
@@ -617,7 +608,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
@@ -644,7 +635,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']
@@ -661,10 +652,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
@@ -1190,11 +1181,16 @@
lx = math.ceil(math.log(x)/math.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 = math.log(x)/math.log(base)
- return lx==int(lx)
+ return abs(lx - nearest_long(lx)) < 1e-10
class LogLocator(Locator):
"""
@@ -1212,7 +1208,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.
|
|
From: <md...@us...> - 2010-10-19 12:44:20
|
Revision: 8755
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8755&view=rev
Author: mdboom
Date: 2010-10-19 12:44:14 +0000 (Tue, 19 Oct 2010)
Log Message:
-----------
Make is_decade safe for non-finite values.
Modified Paths:
--------------
branches/v1_0_maint/lib/matplotlib/ticker.py
Modified: branches/v1_0_maint/lib/matplotlib/ticker.py
===================================================================
--- branches/v1_0_maint/lib/matplotlib/ticker.py 2010-10-15 13:34:49 UTC (rev 8754)
+++ branches/v1_0_maint/lib/matplotlib/ticker.py 2010-10-19 12:44:14 UTC (rev 8755)
@@ -1187,6 +1187,8 @@
else: return long(x-0.5)
def is_decade(x, base=10):
+y if not np.isfinite(x):
+ return False
if x == 0.0:
return True
lx = math.log(x)/math.log(base)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wea...@us...> - 2011-01-05 17:44:26
|
Revision: 8891
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8891&view=rev
Author: weathergod
Date: 2011-01-05 17:44:17 +0000 (Wed, 05 Jan 2011)
Log Message:
-----------
Applying a similar fix to r8873 which seemed to only have been applied to the development branch.
This fixes a math domain error when using log scales.
Modified Paths:
--------------
branches/v1_0_maint/lib/matplotlib/ticker.py
Modified: branches/v1_0_maint/lib/matplotlib/ticker.py
===================================================================
--- branches/v1_0_maint/lib/matplotlib/ticker.py 2011-01-05 16:29:53 UTC (rev 8890)
+++ branches/v1_0_maint/lib/matplotlib/ticker.py 2011-01-05 17:44:17 UTC (rev 8891)
@@ -1194,7 +1194,7 @@
return False
if x == 0.0:
return True
- lx = math.log(x)/math.log(base)
+ lx = math.log(abs(x))/math.log(base)
return is_close_to_int(lx)
def is_close_to_int(x):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|