Revision: 7802
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7802&view=rev
Author: jdh2358
Date: 2009-09-20 22:10:07 +0000 (Sun, 20 Sep 2009)
Log Message:
-----------
some unit cleanup; warn on zero value dates in the formatter
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/__init__.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/axis.py
trunk/matplotlib/lib/matplotlib/cbook.py
trunk/matplotlib/lib/matplotlib/dates.py
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2009-09-20 19:51:44 UTC (rev
7801)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2009-09-20 22:10:07 UTC (rev
7802)
@@ -900,7 +900,7 @@
backend = rcParams['backend']
original_params = rcParams.copy()
- use('Agg') # use Agg backend for these tests
+ use('Agg', warn=False) # use Agg backend for these tests
# These settings *must* be hardcoded for running the comparison
# tests and are not necessarily the default values as specified in
@@ -922,7 +922,7 @@
)
# restore the old backend and rcParams
- use(backend)
+ use(backend, warn=False)
rcParams.update(original_params)
return success
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-09-20 19:51:44 UTC (rev
7801)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-09-20 22:10:07 UTC (rev
7802)
@@ -2306,16 +2306,14 @@
"""
# should be enough to inform the unit conversion interface
# dates are comng in
- self.xaxis.update_units(datetime.date(2009,1,1))
+ self.xaxis.axis_date()
def yaxis_date(self, tz=None):
"""Sets up y-axis ticks and labels that treat the y data as dates.
*tz* is the time zone to use in labeling dates. Defaults to rc value.
"""
- # should be enough to inform the unit conversion interface
- # dates are comng in
- self.yaxis.update_units(datetime.date(2009,1,1))
+ self.yaxis.axis_date()
def format_xdata(self, x):
"""
Modified: trunk/matplotlib/lib/matplotlib/axis.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axis.py 2009-09-20 19:51:44 UTC (rev
7801)
+++ trunk/matplotlib/lib/matplotlib/axis.py 2009-09-20 22:10:07 UTC (rev
7802)
@@ -987,12 +987,17 @@
converter = munits.registry.get_converter(data)
if converter is None: return False
+
+ neednew = self.converter!=converter
self.converter = converter
default = self.converter.default_units(data, self)
#print 'update units: default="%s", units=%s"'%(default, self.units)
if default is not None and self.units is None:
self.set_units(default)
- self._update_axisinfo()
+
+
+ if neednew:
+ self._update_axisinfo()
return True
def _update_axisinfo(self):
@@ -1196,6 +1201,17 @@
"Zoom in/out on axis; if *direction* is >0 zoom in, else zoom out"
self.major.locator.zoom(direction)
+
+ def axis_date(self):
+ """
+ Sets up x-axis ticks and labels that treat the x data as dates.
+ """
+ import datetime
+ # should be enough to inform the unit conversion interface
+ # dates are comng in
+ self.update_units(datetime.date(2009,1,1))
+
+
class XAxis(Axis):
__name__ = 'xaxis'
axis_name = 'x'
@@ -1442,7 +1458,7 @@
if not dataMutated or not viewMutated:
if self.converter is not None:
info = self.converter.axisinfo(self.units, self)
- if info.default_limits is not None:
+ if info.default_limits is not None:
valmin, valmax = info.default_limits
xmin = self.converter.convert(valmin, self.units, self)
xmax = self.converter.convert(valmax, self.units, self)
@@ -1451,8 +1467,8 @@
if not viewMutated:
self.axes.viewLim.intervalx = xmin, xmax
-
+
class YAxis(Axis):
__name__ = 'yaxis'
axis_name = 'y'
@@ -1707,7 +1723,7 @@
if not dataMutated or not viewMutated:
if self.converter is not None:
info = self.converter.axisinfo(self.units, self)
- if info.default_limits is not None:
+ if info.default_limits is not None:
valmin, valmax = info.default_limits
ymin = self.converter.convert(valmin, self.units, self)
ymax = self.converter.convert(valmax, self.units, self)
@@ -1716,4 +1732,4 @@
if not viewMutated:
self.axes.viewLim.intervaly = ymin, ymax
-
+
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py 2009-09-20 19:51:44 UTC (rev
7801)
+++ trunk/matplotlib/lib/matplotlib/cbook.py 2009-09-20 22:10:07 UTC (rev
7802)
@@ -317,7 +317,7 @@
def is_numlike(obj):
'return true if *obj* looks like a number'
try: obj+1
- except TypeError: return False
+ except: return False
else: return True
def to_filehandle(fname, flag='rU', return_opened=False):
Modified: trunk/matplotlib/lib/matplotlib/dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/dates.py 2009-09-20 19:51:44 UTC (rev
7801)
+++ trunk/matplotlib/lib/matplotlib/dates.py 2009-09-20 22:10:07 UTC (rev
7802)
@@ -290,6 +290,8 @@
self.tz = tz
def __call__(self, x, pos=0):
+ if x==0:
+ raise ValueError('DateFormatter found a value of x=0, which is an
illegal date. This usually occurs because you have not informed the axis that
it is plotting dates, eg with ax.xaxis_date()')
dt = num2date(x, self.tz)
return self.strftime(dt, self.fmt)
@@ -430,6 +432,7 @@
}
def __call__(self, x, pos=0):
+
scale = float( self._locator._get_unit() )
fmt = self.defaultfmt
@@ -1065,10 +1068,10 @@
majloc = AutoDateLocator(tz=unit)
majfmt = AutoDateFormatter(majloc, tz=unit)
- datemin = datetime.date(2000, 1, 1)
- datemax = datetime.date(2010, 1, 1)
+ datemin = datetime.date(2000, 1, 1)
+ datemax = datetime.date(2010, 1, 1)
- return units.AxisInfo( majloc=majloc, majfmt=majfmt, label='',
+ return units.AxisInfo( majloc=majloc, majfmt=majfmt, label='',
default_limits=(datemin, datemax))
@staticmethod
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins