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

Function test_date_range_like_errors

xarray/tests/test_cftime_offsets.py:1506–1534  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1504
1505@pytest.mark.filterwarnings("ignore:Converting non-default")
1506def test_date_range_like_errors():
1507 src = date_range("1899-02-03", periods=20, freq="D", use_cftime=False)
1508 src = src[np.arange(20) != 10] # Remove 1 day so the frequency is not inferable.
1509
1510 with pytest.raises(
1511 ValueError,
1512 match=r"`date_range_like` was unable to generate a range as the source frequency was not inferable.",
1513 ):
1514 date_range_like(src, "gregorian")
1515
1516 src = DataArray(
1517 np.array(
1518 [["1999-01-01", "1999-01-02"], ["1999-01-03", "1999-01-04"]],
1519 dtype=np.datetime64,
1520 ),
1521 dims=("x", "y"),
1522 )
1523 with pytest.raises(
1524 ValueError,
1525 match=r"'source' must be a 1D array of datetime objects for inferring its range.",
1526 ):
1527 date_range_like(src, "noleap")
1528
1529 da = DataArray([1, 2, 3, 4], dims=("time",))
1530 with pytest.raises(
1531 ValueError,
1532 match=r"'source' must be a 1D array of datetime objects for inferring its range.",
1533 ):
1534 date_range_like(da, "noleap")
1535
1536
1537def as_timedelta_not_implemented_error():

Callers

nothing calls this directly

Calls 4

date_rangeFunction · 0.90
date_range_likeFunction · 0.90
DataArrayClass · 0.90
arangeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…