(calendar: str)
| 223 | "calendar", ["gregorian", "noleap", "all_leap", "360_day", "julian"] |
| 224 | ) |
| 225 | def test_calendars(calendar: str) -> None: |
| 226 | # Limited testing for non-standard calendars |
| 227 | freq, closed, label = "8001min", None, None |
| 228 | xr_index = xr.date_range( |
| 229 | start="2004-01-01T12:07:01", |
| 230 | periods=7, |
| 231 | freq="3D", |
| 232 | calendar=calendar, |
| 233 | use_cftime=True, |
| 234 | ) |
| 235 | pd_index = pd.date_range( |
| 236 | start="2004-01-01T12:07:01", periods=7, freq="3D", unit="ns" |
| 237 | ) |
| 238 | da_cftime = da(xr_index).resample(time=freq, closed=closed, label=label).mean() |
| 239 | da_datetime = da(pd_index).resample(time=freq, closed=closed, label=label).mean() |
| 240 | # TODO (benbovy - flexible indexes): update when CFTimeIndex is an xarray Index subclass |
| 241 | new_pd_index = da_cftime.xindexes["time"].to_pandas_index() |
| 242 | assert isinstance(new_pd_index, CFTimeIndex) # shouldn't that be a pd.Index? |
| 243 | da_cftime["time"] = new_pd_index.to_datetimeindex(time_unit="ns") |
| 244 | xr.testing.assert_identical(da_cftime, da_datetime) |
| 245 | |
| 246 | |
| 247 | class DateRangeKwargs(TypedDict): |
nothing calls this directly
no test coverage detected
searching dependent graphs…