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

Function test_YearLocator

lib/matplotlib/tests/test_dates.py:1146–1182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1144
1145
1146def test_YearLocator():
1147 def _create_year_locator(date1, date2, **kwargs):
1148 locator = mdates.YearLocator(**kwargs)
1149 locator.create_dummy_axis()
1150 locator.axis.set_view_interval(mdates.date2num(date1),
1151 mdates.date2num(date2))
1152 return locator
1153
1154 d1 = datetime.datetime(1990, 1, 1)
1155 results = ([datetime.timedelta(weeks=52 * 200),
1156 {'base': 20, 'month': 1, 'day': 1},
1157 ['1980-01-01 00:00:00+00:00', '2000-01-01 00:00:00+00:00',
1158 '2020-01-01 00:00:00+00:00', '2040-01-01 00:00:00+00:00',
1159 '2060-01-01 00:00:00+00:00', '2080-01-01 00:00:00+00:00',
1160 '2100-01-01 00:00:00+00:00', '2120-01-01 00:00:00+00:00',
1161 '2140-01-01 00:00:00+00:00', '2160-01-01 00:00:00+00:00',
1162 '2180-01-01 00:00:00+00:00', '2200-01-01 00:00:00+00:00']
1163 ],
1164 [datetime.timedelta(weeks=52 * 200),
1165 {'base': 20, 'month': 5, 'day': 16},
1166 ['1980-05-16 00:00:00+00:00', '2000-05-16 00:00:00+00:00',
1167 '2020-05-16 00:00:00+00:00', '2040-05-16 00:00:00+00:00',
1168 '2060-05-16 00:00:00+00:00', '2080-05-16 00:00:00+00:00',
1169 '2100-05-16 00:00:00+00:00', '2120-05-16 00:00:00+00:00',
1170 '2140-05-16 00:00:00+00:00', '2160-05-16 00:00:00+00:00',
1171 '2180-05-16 00:00:00+00:00', '2200-05-16 00:00:00+00:00']
1172 ],
1173 [datetime.timedelta(weeks=52 * 5),
1174 {'base': 20, 'month': 9, 'day': 25},
1175 ['1980-09-25 00:00:00+00:00', '2000-09-25 00:00:00+00:00']
1176 ],
1177 )
1178
1179 for delta, arguments, expected in results:
1180 d2 = d1 + delta
1181 locator = _create_year_locator(d1, d2, **arguments)
1182 assert list(map(str, mdates.num2date(locator()))) == expected
1183
1184
1185def test_DayLocator():

Callers

nothing calls this directly

Calls 1

_create_year_locatorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…