(calendar, time_unit: PDDatetimeUnitOptions)
| 700 | |
| 701 | @pytest.mark.parametrize("calendar", _ALL_CALENDARS) |
| 702 | def test_decode_cf(calendar, time_unit: PDDatetimeUnitOptions) -> None: |
| 703 | days = [1.0, 2.0, 3.0] |
| 704 | # TODO: GH5690 — do we want to allow this type for `coords`? |
| 705 | da = DataArray(days, coords=[days], dims=["time"], name="test") |
| 706 | ds = da.to_dataset() |
| 707 | |
| 708 | for v in ["test", "time"]: |
| 709 | ds[v].attrs["units"] = "days since 2001-01-01" |
| 710 | ds[v].attrs["calendar"] = calendar |
| 711 | |
| 712 | if not has_cftime and calendar not in _STANDARD_CALENDAR_NAMES: |
| 713 | with pytest.raises(ValueError): |
| 714 | ds = decode_cf(ds) |
| 715 | else: |
| 716 | ds = decode_cf(ds, decode_times=CFDatetimeCoder(time_unit=time_unit)) |
| 717 | |
| 718 | if calendar not in _STANDARD_CALENDAR_NAMES: |
| 719 | assert ds.test.dtype == np.dtype("O") |
| 720 | else: |
| 721 | assert ds.test.dtype == np.dtype(f"=M8[{time_unit}]") |
| 722 | |
| 723 | |
| 724 | def test_decode_cf_time_bounds(time_unit: PDDatetimeUnitOptions) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…