(
time_unit: PDDatetimeUnitOptions, encoding_unit
)
| 634 | |
| 635 | @pytest.mark.parametrize("encoding_unit", FREQUENCIES_TO_ENCODING_UNITS.values()) |
| 636 | def test_decode_cf_timedelta_time_unit( |
| 637 | time_unit: PDDatetimeUnitOptions, encoding_unit |
| 638 | ) -> None: |
| 639 | encoded = 1 |
| 640 | encoding_unit_as_numpy = _netcdf_to_numpy_timeunit(encoding_unit) |
| 641 | if np.timedelta64(1, time_unit) > np.timedelta64(1, encoding_unit_as_numpy): |
| 642 | expected = np.timedelta64(encoded, encoding_unit_as_numpy) |
| 643 | else: |
| 644 | expected = np.timedelta64(encoded, encoding_unit_as_numpy).astype( |
| 645 | f"timedelta64[{time_unit}]" |
| 646 | ) |
| 647 | result = decode_cf_timedelta(encoded, encoding_unit, time_unit) |
| 648 | assert result == expected |
| 649 | assert result.dtype == expected.dtype |
| 650 | |
| 651 | |
| 652 | def test_decode_cf_timedelta_time_unit_out_of_bounds( |
nothing calls this directly
no test coverage detected
searching dependent graphs…