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

Function test_cftime_list_of_strings

xarray/tests/test_interp.py:780–796  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

778@requires_cftime
779@requires_scipy
780def test_cftime_list_of_strings() -> None:
781 from cftime import DatetimeProlepticGregorian
782
783 times = xr.date_range(
784 "2000", periods=24, freq="D", calendar="proleptic_gregorian", use_cftime=True
785 )
786 da = xr.DataArray(np.arange(24), coords=[times], dims="time")
787
788 times_new = ["2000-01-01T12:00", "2000-01-02T12:00", "2000-01-03T12:00"]
789 actual = da.interp(time=times_new)
790
791 times_new_array = _parse_array_of_cftime_strings(
792 np.array(times_new), DatetimeProlepticGregorian
793 )
794 expected = xr.DataArray([0.5, 1.5, 2.5], coords=[times_new_array], dims=["time"])
795
796 assert_allclose(actual, expected)
797
798
799@requires_cftime

Callers

nothing calls this directly

Calls 4

interpMethod · 0.95
assert_allcloseFunction · 0.90
arangeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…