MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_too_many_date_ticks

Function test_too_many_date_ticks

lib/matplotlib/tests/test_dates.py:191–216  ·  view source on GitHub ↗
(caplog)

Source from the content-addressed store, hash-verified

189
190
191def test_too_many_date_ticks(caplog):
192 # Attempt to test SF 2715172, see
193 # https://sourceforge.net/tracker/?func=detail&aid=2715172&group_id=80706&atid=560720
194 # setting equal datetimes triggers and expander call in
195 # transforms.nonsingular which results in too many ticks in the
196 # DayLocator. This should emit a log at WARNING level.
197 caplog.set_level("WARNING")
198 t0 = datetime.datetime(2000, 1, 20)
199 tf = datetime.datetime(2000, 1, 20)
200 fig, ax = plt.subplots()
201 with pytest.warns(UserWarning) as rec:
202 ax.set_xlim(t0, tf, auto=True)
203 assert len(rec) == 1
204 assert ('Attempting to set identical low and high xlims'
205 in str(rec[0].message))
206 ax.plot([], [])
207 ax.xaxis.set_major_locator(mdates.DayLocator())
208 v = ax.xaxis.get_major_locator()()
209 assert len(v) > 1000
210 # The warning is emitted multiple times because the major locator is also
211 # called both when placing the minor ticks (for overstriking detection) and
212 # during tick label positioning.
213 assert caplog.records and all(
214 record.name == "matplotlib.ticker" and record.levelname == "WARNING"
215 for record in caplog.records)
216 assert len(caplog.records) > 0
217
218
219def _new_epoch_decorator(thefunc):

Callers

nothing calls this directly

Calls 5

get_major_locatorMethod · 0.80
subplotsMethod · 0.45
set_xlimMethod · 0.45
plotMethod · 0.45
set_major_locatorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…