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

Function test_roundtrip_float_times

xarray/tests/test_coding_times.py:1590–1608  ·  view source on GitHub ↗
(fill_value, times, units, encoded_values)

Source from the content-addressed store, hash-verified

1588 ids=_TEST_ROUNDTRIP_FLOAT_TIMES_TESTS.keys(),
1589)
1590def test_roundtrip_float_times(fill_value, times, units, encoded_values) -> None:
1591 # Regression test for GitHub issues #8271 and #9488
1592 var = Variable(
1593 ["time"],
1594 times,
1595 encoding=dict(dtype=np.float64, _FillValue=fill_value, units=units),
1596 )
1597
1598 encoded_var = conventions.encode_cf_variable(var)
1599 np.testing.assert_array_equal(encoded_var, encoded_values)
1600 assert encoded_var.attrs["units"] == units
1601 assert encoded_var.attrs["_FillValue"] == fill_value
1602
1603 decoded_var = conventions.decode_cf_variable(
1604 "foo", encoded_var, decode_timedelta=CFTimedeltaCoder(time_unit="ns")
1605 )
1606 assert_identical(var, decoded_var)
1607 assert decoded_var.encoding["units"] == units
1608 assert decoded_var.encoding["_FillValue"] == fill_value
1609
1610
1611_ENCODE_DATETIME64_VIA_DASK_TESTS = {

Callers

nothing calls this directly

Calls 3

VariableClass · 0.90
assert_identicalFunction · 0.90
CFTimedeltaCoderClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…