Skip to content

Commit 7f8c295

Browse files
author
LindyBalboa
committed
Add parameter checks to DayLocator initiator
Check that interval parameter is an integer greater than zero. Delete unuseful 'optimization' meant to prevent exceeding the MAXTICKS variable. During testing it seemed ineffective. The following Locator.raise_if_exceeds exception was triggered first anyways. resolves #6935
1 parent 22aa800 commit 7f8c295

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lib/matplotlib/dates.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -821,19 +821,6 @@ def tick_values(self, vmin, vmax):
821821

822822
self.rule.set(dtstart=start, until=stop)
823823

824-
# estimate the number of ticks very approximately so we don't
825-
# have to do a very expensive (and potentially near infinite)
826-
# 'between' calculation, only to find out it will fail.
827-
nmax, nmin = date2num((vmax, vmin))
828-
estimate = (nmax - nmin) / (self._get_unit() * self._get_interval())
829-
# This estimate is only an estimate, so be really conservative
830-
# about bailing...
831-
if estimate > self.MAXTICKS * 2:
832-
raise RuntimeError(
833-
'RRuleLocator estimated to generate %d ticks from %s to %s: '
834-
'exceeds Locator.MAXTICKS * 2 (%d) ' % (estimate, vmin, vmax,
835-
self.MAXTICKS * 2))
836-
837824
dates = self.rule.between(vmin, vmax, True)
838825
if len(dates) == 0:
839826
return date2num([vmin, vmax])
@@ -1254,6 +1241,12 @@ def __init__(self, bymonthday=None, interval=1, tz=None):
12541241
12551242
Default is to tick every day of the month: ``bymonthday=range(1,32)``
12561243
"""
1244+
if interval < 1:
1245+
raise ValueError("The interval parameter must be an integer "
1246+
"greater than or equal to one.")
1247+
if not isinstance(interval, int):
1248+
raise ValueError("The interval parameter must be an integer "
1249+
"greater than or equal to one.")
12571250
if bymonthday is None:
12581251
bymonthday = range(1, 32)
12591252
elif isinstance(bymonthday, np.ndarray):

0 commit comments

Comments
 (0)