MCPcopy
hub / github.com/pydata/xarray / test_to_offset_annual

Function test_to_offset_annual

xarray/tests/test_cftime_offsets.py:273–290  ·  view source on GitHub ↗
(month_label, month_int, multiple, offset_str)

Source from the content-addressed store, hash-verified

271@pytest.mark.parametrize("offset_str", ["AS", "A", "YS", "Y"])
272@pytest.mark.filterwarnings("ignore::FutureWarning") # Deprecation of "A" etc.
273def test_to_offset_annual(month_label, month_int, multiple, offset_str):
274 freq = offset_str
275 offset_type = _ANNUAL_OFFSET_TYPES[offset_str]
276 if month_label:
277 freq = f"{freq}-{month_label}"
278 if multiple:
279 freq = f"{multiple}{freq}"
280 result = to_offset(freq)
281
282 if multiple and month_int:
283 expected = offset_type(n=multiple, month=month_int)
284 elif multiple:
285 expected = offset_type(n=multiple)
286 elif month_int:
287 expected = offset_type(month=month_int)
288 else:
289 expected = offset_type()
290 assert result == expected
291
292
293_QUARTER_OFFSET_TYPES = {"Q": QuarterEnd, "QS": QuarterBegin, "QE": QuarterEnd}

Callers

nothing calls this directly

Calls 1

to_offsetFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…