From: <jd...@us...> - 2009-09-07 18:50:18
|
Revision: 7677 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7677&view=rev Author: jdh2358 Date: 2009-09-07 18:50:11 +0000 (Mon, 07 Sep 2009) Log Message: ----------- use the max tick limit for all tick locators Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/dates.py trunk/matplotlib/lib/matplotlib/ticker.py Modified: trunk/matplotlib/lib/matplotlib/dates.py =================================================================== --- trunk/matplotlib/lib/matplotlib/dates.py 2009-09-07 18:42:41 UTC (rev 7676) +++ trunk/matplotlib/lib/matplotlib/dates.py 2009-09-07 18:50:11 UTC (rev 7677) @@ -522,9 +522,7 @@ self.rule.set(dtstart=start, until=stop) dates = self.rule.between(dmin, dmax, True) - if len(dates)>=ticker.Locator.MAXTICKS: - raise RuntimeError('RRuleLocator attempting to generate %d ticks from %s to %s: exceeds matplotlib.ticker.Locator.MAXTICKS'%(len(dates), dates[0], dates[-1])) - return date2num(dates) + return self.raise_if_exceeds(date2num(dates)) def _get_unit(self): """ Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2009-09-07 18:42:41 UTC (rev 7676) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2009-09-07 18:50:11 UTC (rev 7677) @@ -669,6 +669,13 @@ 'Return the locations of the ticks' raise NotImplementedError('Derived must override') + def raise_if_exceeds(self, locs): + 'raise a RuntimeError if Locator attempts to create more than MAXTICKS locs' + if len(locs)>=self.MAXTICKS: + raise RuntimeError('Locator attempting to generate %d ticks from %s to %s: exceeds Locator.MAXTICKS'%(len(locs), locs[0], locs[-1])) + + return locs + def view_limits(self, vmin, vmax): """ select a scale for the range from vmin to vmax @@ -728,7 +735,8 @@ def __call__(self): 'Return the locations of the ticks' dmin, dmax = self.axis.get_data_interval() - return np.arange(dmin + self.offset, dmax+1, self._base) + return self.raise_if_exceeds( + np.arange(dmin + self.offset, dmax+1, self._base)) class FixedLocator(Locator): @@ -758,7 +766,7 @@ ticks1 = self.locs[i::step] if np.absolute(ticks1).min() < np.absolute(ticks).min(): ticks = ticks1 - return ticks + return self.raise_if_exceeds(ticks) @@ -812,7 +820,7 @@ if self.numticks==0: return [] ticklocs = np.linspace(vmin, vmax, self.numticks) - return ticklocs + return self.raise_if_exceeds(ticklocs) def _set_numticks(self): @@ -900,7 +908,7 @@ base = self._base.get_base() n = (vmax - vmin + 0.001*base)//base locs = vmin + np.arange(n+1) * base - return locs + return self.raise_if_exceeds(locs) def view_limits(self, dmin, dmax): """ @@ -1010,7 +1018,7 @@ locs = locs[:-1] elif prune=='both': locs = locs[1:-1] - return locs + return self.raise_if_exceeds(locs) def view_limits(self, dmin, dmax): if self._symmetric: @@ -1106,7 +1114,7 @@ else: ticklocs = b**decades - return np.array(ticklocs) + return self.raise_if_exceeds(np.array(ticklocs)) def view_limits(self, vmin, vmax): 'Try to choose the view limits intelligently' @@ -1177,7 +1185,7 @@ ticklocs.extend(subs * (np.sign(decade) * b ** np.abs(decade))) else: ticklocs = np.sign(decades) * b ** np.abs(decades) - return np.array(ticklocs) + return self.raise_if_exceeds(np.array(ticklocs)) def view_limits(self, vmin, vmax): 'Try to choose the view limits intelligently' @@ -1241,7 +1249,7 @@ if vmin > vmax: vmin,vmax = vmax,vmin - return locs[(vmin < locs) & (locs < vmax)] + return self.raise_if_exceeds(locs[(vmin < locs) & (locs < vmax)]) class OldAutoLocator(Locator): @@ -1256,7 +1264,7 @@ def __call__(self): 'Return the locations of the ticks' self.refresh() - return self._locator() + return self.raise_if_exceeds(self._locator()) def refresh(self): 'refresh internal information based on current lim' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |