MCPcopy
hub / github.com/pydata/xarray / test_encode_decode_roundtrip_datetime64

Function test_encode_decode_roundtrip_datetime64

xarray/tests/test_coding_times.py:1109–1121  ·  view source on GitHub ↗
(
    freq, time_unit: PDDatetimeUnitOptions
)

Source from the content-addressed store, hash-verified

1107
1108@pytest.mark.parametrize("freq", FREQUENCIES_TO_ENCODING_UNITS.keys())
1109def test_encode_decode_roundtrip_datetime64(
1110 freq, time_unit: PDDatetimeUnitOptions
1111) -> None:
1112 # See GH 4045. Prior to GH 4684 this test would fail for frequencies of
1113 # "s", "ms", "us", and "ns".
1114 initial_time = pd.date_range("1678-01-01", periods=1)
1115 times = initial_time.append(pd.date_range("1968", periods=2, freq=freq))
1116 variable = Variable(["time"], times)
1117 encoded = conventions.encode_cf_variable(variable)
1118 decoded = conventions.decode_cf_variable(
1119 "time", encoded, decode_times=CFDatetimeCoder(time_unit=time_unit)
1120 )
1121 assert_equal(variable, decoded)
1122
1123
1124@requires_cftime

Callers

nothing calls this directly

Calls 3

VariableClass · 0.90
assert_equalFunction · 0.90
CFDatetimeCoderClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…