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

Function test_decode_cf_timedelta_time_unit

xarray/tests/test_coding_times.py:636–649  ·  view source on GitHub ↗
(
    time_unit: PDDatetimeUnitOptions, encoding_unit
)

Source from the content-addressed store, hash-verified

634
635@pytest.mark.parametrize("encoding_unit", FREQUENCIES_TO_ENCODING_UNITS.values())
636def 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
652def test_decode_cf_timedelta_time_unit_out_of_bounds(

Callers

nothing calls this directly

Calls 3

decode_cf_timedeltaFunction · 0.90
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…