MCPcopy Index your code
hub / github.com/pydata/xarray / test_convert_calendar_errors

Function test_convert_calendar_errors

xarray/tests/test_calendar_ops.py:215–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

213
214@requires_cftime
215def test_convert_calendar_errors():
216 src_nl = DataArray(
217 date_range("0000-01-01", "0000-12-31", freq="D", calendar="noleap"),
218 dims=("time",),
219 name="time",
220 )
221 # no align_on for conversion to 360_day
222 with pytest.raises(ValueError, match="Argument `align_on` must be specified"):
223 convert_calendar(src_nl, "360_day")
224
225 # Standard doesn't support year 0
226 with pytest.raises(
227 ValueError, match="Source time coordinate contains dates with year 0"
228 ):
229 convert_calendar(src_nl, "standard")
230
231 # no align_on for conversion from 360 day
232 src_360 = convert_calendar(src_nl, "360_day", align_on="year")
233 with pytest.raises(ValueError, match="Argument `align_on` must be specified"):
234 convert_calendar(src_360, "noleap")
235
236 # Datetime objects
237 da = DataArray([0, 1, 2], dims=("x",), name="x")
238 with pytest.raises(
239 ValueError, match=r"Coordinate x must contain datetime objects."
240 ):
241 convert_calendar(da, "standard", dim="x")
242
243
244def test_convert_calendar_dimension_name():

Callers

nothing calls this directly

Calls 3

DataArrayClass · 0.90
date_rangeFunction · 0.90
convert_calendarFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…