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

Function test_to_datetimeindex

xarray/tests/test_cftimeindex.py:1234–1246  ·  view source on GitHub ↗
(calendar, unsafe)

Source from the content-addressed store, hash-verified

1232@pytest.mark.parametrize("calendar", _ALL_CALENDARS)
1233@pytest.mark.parametrize("unsafe", [False, True])
1234def test_to_datetimeindex(calendar, unsafe) -> None:
1235 index = xr.date_range("2000", periods=5, calendar=calendar, use_cftime=True)
1236 expected = pd.date_range("2000", periods=5, unit="ns")
1237
1238 if calendar in _NON_STANDARD_CALENDAR_NAMES and not unsafe:
1239 with pytest.warns(RuntimeWarning, match="non-standard"):
1240 result = index.to_datetimeindex(time_unit="ns")
1241 else:
1242 result = index.to_datetimeindex(unsafe=unsafe, time_unit="ns")
1243
1244 assert result.equals(expected)
1245 np.testing.assert_array_equal(result, expected)
1246 assert isinstance(result, pd.DatetimeIndex)
1247
1248
1249@requires_cftime

Callers

nothing calls this directly

Calls 2

to_datetimeindexMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…