From: <jr...@us...> - 2009-01-29 17:57:50
|
Revision: 6849 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6849&view=rev Author: jrevans Date: 2009-01-29 17:57:43 +0000 (Thu, 29 Jan 2009) Log Message: ----------- hanged the order of arguments for unit.ConverterInterface class. Modified Paths: -------------- trunk/matplotlib/examples/units/basic_units.py trunk/matplotlib/lib/matplotlib/axis.py trunk/matplotlib/lib/matplotlib/dates.py trunk/matplotlib/lib/matplotlib/units.py Modified: trunk/matplotlib/examples/units/basic_units.py =================================================================== --- trunk/matplotlib/examples/units/basic_units.py 2009-01-29 17:18:50 UTC (rev 6848) +++ trunk/matplotlib/examples/units/basic_units.py 2009-01-29 17:57:43 UTC (rev 6849) @@ -98,6 +98,9 @@ '__sub__':ConvertAllProxy, '__mul__':ConvertAllProxy, '__rmul__':ConvertAllProxy, + '__cmp__':ConvertAllProxy, + '__lt__':ConvertAllProxy, + '__gt__':ConvertAllProxy, '__len__':PassThroughProxy} def __new__(cls, value, unit): @@ -228,7 +231,7 @@ return self.conversions[unit] def convert_value_to(self, value, unit): - #print 'convert value to: value ="%s", unit="%s"'%(value, type(unit)), self.conversions + #print 'convert value to: value ="%s", unit="%s"'%(value, type(unit)), self.conversions conversion_fn = self.conversions[unit] ret = conversion_fn(value) return ret Modified: trunk/matplotlib/lib/matplotlib/axis.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axis.py 2009-01-29 17:18:50 UTC (rev 6848) +++ trunk/matplotlib/lib/matplotlib/axis.py 2009-01-29 17:57:43 UTC (rev 6849) @@ -939,7 +939,7 @@ converter = munits.registry.get_converter(data) if converter is None: return False self.converter = converter - default = self.converter.default_units(self, data) + 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) @@ -955,7 +955,7 @@ if self.converter is None: return - info = self.converter.axisinfo(self, self.units) + info = self.converter.axisinfo(self.units, self) if info is None: return if info.majloc is not None and self.major.locator!=info.majloc: @@ -982,7 +982,7 @@ #print 'convert_units returning identity: units=%s, converter=%s'%(self.units, self.converter) return x - ret = self.converter.convert(self, x, self.units) + ret = self.converter.convert(x, self.units, self) #print 'convert_units converting: axis=%s, units=%s, converter=%s, in=%s, out=%s'%(self, self.units, self.converter, x, ret) return ret Modified: trunk/matplotlib/lib/matplotlib/dates.py =================================================================== --- trunk/matplotlib/lib/matplotlib/dates.py 2009-01-29 17:18:50 UTC (rev 6848) +++ trunk/matplotlib/lib/matplotlib/dates.py 2009-01-29 17:57:43 UTC (rev 6849) @@ -1007,51 +1007,52 @@ """The units are equivalent to the timezone.""" @staticmethod - def axisinfo(axis, unit): + def axisinfo(unit, axis): 'return the unit AxisInfo' # make sure that the axis does not start at 0 - ax = axis.axes + if axis: + ax = axis.axes - if axis is ax.get_xaxis(): - xmin, xmax = ax.dataLim.intervalx - if xmin==0.: - # no data has been added - let's set the default datalim. - # We should probably use a better proxy for the datalim - # have been updated than the ignore setting - dmax = today = datetime.date.today() - dmin = today-datetime.timedelta(days=10) + if axis is ax.get_xaxis(): + xmin, xmax = ax.dataLim.intervalx + if xmin==0.: + # no data has been added - let's set the default datalim. + # We should probably use a better proxy for the datalim + # have been updated than the ignore setting + dmax = today = datetime.date.today() + dmin = today-datetime.timedelta(days=10) - ax._process_unit_info(xdata=(dmin, dmax)) - dmin, dmax = ax.convert_xunits([dmin, dmax]) + ax._process_unit_info(xdata=(dmin, dmax)) + dmin, dmax = ax.convert_xunits([dmin, dmax]) - ax.viewLim.intervalx = dmin, dmax - ax.dataLim.intervalx = dmin, dmax - elif axis is ax.get_yaxis(): - ymin, ymax = ax.dataLim.intervaly - if ymin==0.: - # no data has been added - let's set the default datalim. - # We should probably use a better proxy for the datalim - # have been updated than the ignore setting - dmax = today = datetime.date.today() - dmin = today-datetime.timedelta(days=10) + ax.viewLim.intervalx = dmin, dmax + ax.dataLim.intervalx = dmin, dmax + elif axis is ax.get_yaxis(): + ymin, ymax = ax.dataLim.intervaly + if ymin==0.: + # no data has been added - let's set the default datalim. + # We should probably use a better proxy for the datalim + # have been updated than the ignore setting + dmax = today = datetime.date.today() + dmin = today-datetime.timedelta(days=10) - ax._process_unit_info(ydata=(dmin, dmax)) - dmin, dmax = ax.convert_yunits([dmin, dmax]) + ax._process_unit_info(ydata=(dmin, dmax)) + dmin, dmax = ax.convert_yunits([dmin, dmax]) - ax.viewLim.intervaly = dmin, dmax - ax.dataLim.intervaly = dmin, dmax + ax.viewLim.intervaly = dmin, dmax + ax.dataLim.intervaly = dmin, dmax majloc = AutoDateLocator(tz=unit) majfmt = AutoDateFormatter(majloc, tz=unit) return units.AxisInfo( majloc=majloc, majfmt=majfmt, label='' ) @staticmethod - def convert(axis, value, unit): + def convert(value, unit, axis): if units.ConversionInterface.is_numlike(value): return value return date2num(value) @staticmethod - def default_units(axis, x): + def default_units(x, axis): 'Return the default unit for *x* or None' return None Modified: trunk/matplotlib/lib/matplotlib/units.py =================================================================== --- trunk/matplotlib/lib/matplotlib/units.py 2009-01-29 17:18:50 UTC (rev 6848) +++ trunk/matplotlib/lib/matplotlib/units.py 2009-01-29 17:57:43 UTC (rev 6849) @@ -69,17 +69,17 @@ sequences) and convert them to values mpl can use """ @staticmethod - def axisinfo(axis, unit): + def axisinfo(unit, axis): 'return an units.AxisInfo instance for axis with the specified units' return None @staticmethod - def default_units(axis, x): + def default_units(x, axis): 'return the default unit for x or None for the given axis' return None @staticmethod - def convert(axis, obj, unit): + def convert(obj, unit, axis): """ convert obj using unit for the specified axis. If obj is a sequence, return the converted sequence. The ouput must be a sequence of scalars This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |