Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 565d83f

Browse files
committed
Deprecate MAXTICKS, Locator.raise_if_exceeds.
1 parent c44556f commit 565d83f

File tree

3 files changed

+15
-32
lines changed

3 files changed

+15
-32
lines changed

lib/matplotlib/dates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ def tick_values(self, vmin, vmax):
822822
dates = self.rule.between(vmin, vmax, True)
823823
if len(dates) == 0:
824824
return date2num([vmin, vmax])
825-
return self.raise_if_exceeds(date2num(dates))
825+
return date2num(dates)
826826

827827
def _get_unit(self):
828828
"""

lib/matplotlib/tests/test_dates.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,6 @@ def test_date_axvline():
8888
fig.autofmt_xdate()
8989

9090

91-
def test_too_many_date_ticks():
92-
# Attempt to test SF 2715172, see
93-
# https://sourceforge.net/tracker/?func=detail&aid=2715172&group_id=80706&atid=560720
94-
# setting equal datetimes triggers and expander call in
95-
# transforms.nonsingular which results in too many ticks in the
96-
# DayLocator. This should trigger a Locator.MAXTICKS RuntimeError
97-
t0 = datetime.datetime(2000, 1, 20)
98-
tf = datetime.datetime(2000, 1, 20)
99-
fig = plt.figure()
100-
ax = fig.add_subplot(1, 1, 1)
101-
ax.set_xlim((t0, tf), auto=True)
102-
ax.plot([], [])
103-
ax.xaxis.set_major_locator(mdates.DayLocator())
104-
with pytest.raises(RuntimeError):
105-
fig.savefig('junk.png')
106-
107-
10891
@image_comparison(baseline_images=['RRuleLocator_bounds'], extensions=['png'])
10992
def test_RRuleLocator():
11093
import matplotlib.testing.jpl_units as units

lib/matplotlib/ticker.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,10 @@ class Locator(TickHelper):
13871387
# kill the machine when you try and render them.
13881388
# This parameter is set to cause locators to raise an error if too
13891389
# many ticks are generated.
1390-
MAXTICKS = 1000
1390+
@property
1391+
@cbook.deprecated("2.1")
1392+
def MAXTICKS(self):
1393+
return 1000
13911394

13921395
def tick_values(self, vmin, vmax):
13931396
"""
@@ -1420,6 +1423,7 @@ def __call__(self):
14201423
# hence there is no *one* interface to call self.tick_values.
14211424
raise NotImplementedError('Derived must override')
14221425

1426+
@cbook.deprecated("2.1")
14231427
def raise_if_exceeds(self, locs):
14241428
"""raise a RuntimeError if Locator attempts to create more than
14251429
MAXTICKS locs"""
@@ -1546,7 +1550,7 @@ def tick_values(self, vmin, vmax):
15461550
ticks1 = self.locs[i::step]
15471551
if np.abs(ticks1).min() < np.abs(ticks).min():
15481552
ticks = ticks1
1549-
return self.raise_if_exceeds(ticks)
1553+
return ticks
15501554

15511555

15521556
class NullLocator(Locator):
@@ -1605,18 +1609,14 @@ def tick_values(self, vmin, vmax):
16051609
vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05)
16061610
if vmax < vmin:
16071611
vmin, vmax = vmax, vmin
1608-
16091612
if (vmin, vmax) in self.presets:
16101613
return self.presets[(vmin, vmax)]
1611-
16121614
if self.numticks is None:
16131615
self._set_numticks()
1614-
16151616
if self.numticks == 0:
16161617
return []
16171618
ticklocs = np.linspace(vmin, vmax, self.numticks)
1618-
1619-
return self.raise_if_exceeds(ticklocs)
1619+
return ticklocs
16201620

16211621
def _set_numticks(self):
16221622
self.numticks = 11 # todo; be smart here; this is just for dev
@@ -1716,7 +1716,7 @@ def tick_values(self, vmin, vmax):
17161716
base = self._base.get_base()
17171717
n = (vmax - vmin + 0.001 * base) // base
17181718
locs = vmin - base + np.arange(n + 3) * base
1719-
return self.raise_if_exceeds(locs)
1719+
return locs
17201720

17211721
def view_limits(self, dmin, dmax):
17221722
"""
@@ -1931,7 +1931,7 @@ def tick_values(self, vmin, vmax):
19311931
locs = locs[:-1]
19321932
elif prune == 'both':
19331933
locs = locs[1:-1]
1934-
return self.raise_if_exceeds(locs)
1934+
return locs
19351935

19361936
def view_limits(self, dmin, dmax):
19371937
if self._symmetric:
@@ -2133,7 +2133,7 @@ def tick_values(self, vmin, vmax):
21332133
else:
21342134
ticklocs = b ** decades
21352135

2136-
return self.raise_if_exceeds(np.asarray(ticklocs))
2136+
return np.asarray(ticklocs)
21372137

21382138
def view_limits(self, vmin, vmax):
21392139
'Try to choose the view limits intelligently'
@@ -2314,7 +2314,7 @@ def get_log_range(lo, hi):
23142314
else:
23152315
ticklocs = decades
23162316

2317-
return self.raise_if_exceeds(np.array(ticklocs))
2317+
return np.array(ticklocs)
23182318

23192319
def view_limits(self, vmin, vmax):
23202320
'Try to choose the view limits intelligently'
@@ -2405,7 +2405,7 @@ def tick_values(self, vmin, vmax):
24052405
newticks = 1 - np.outer(np.arange(2, 10), 10**expo).ravel()
24062406
ticklocs.extend(list(newticks))
24072407

2408-
return self.raise_if_exceeds(np.array(ticklocs))
2408+
return np.array(ticklocs)
24092409

24102410
def nonsingular(self, vmin, vmax):
24112411
initial_range = (1e-7, 1 - 1e-7)
@@ -2510,7 +2510,7 @@ def __call__(self):
25102510
else:
25112511
locs = []
25122512

2513-
return self.raise_if_exceeds(np.array(locs))
2513+
return np.array(locs)
25142514

25152515
def tick_values(self, vmin, vmax):
25162516
raise NotImplementedError('Cannot get tick locations for a '
@@ -2529,7 +2529,7 @@ def __init__(self):
25292529
def __call__(self):
25302530
'Return the locations of the ticks'
25312531
self.refresh()
2532-
return self.raise_if_exceeds(self._locator())
2532+
return self._locator()
25332533

25342534
def tick_values(self, vmin, vmax):
25352535
raise NotImplementedError('Cannot get tick locations for a '

0 commit comments

Comments
 (0)