MCPcopy Create free account
hub / github.com/pydata/xarray / test_np_timedelta64_to_float

Function test_np_timedelta64_to_float

xarray/tests/test_duck_array_ops.py:1051–1064  ·  view source on GitHub ↗
(
    np_dt_unit: NPDatetimeUnitOptions, time_unit: PDDatetimeUnitOptions
)

Source from the content-addressed store, hash-verified

1049
1050@pytest.mark.parametrize("np_dt_unit", ["D", "h", "m", "s", "ms", "us", "ns"])
1051def test_np_timedelta64_to_float(
1052 np_dt_unit: NPDatetimeUnitOptions, time_unit: PDDatetimeUnitOptions
1053):
1054 # tests any combination of source np.timedelta64 (NPDatetimeUnitOptions) with
1055 # np_timedelta_to_float with dedicated target unit (PDDatetimeUnitOptions)
1056 td = np.timedelta64(1, np_dt_unit)
1057 expected = _NS_PER_TIME_DELTA[np_dt_unit] / _NS_PER_TIME_DELTA[time_unit]
1058
1059 out = np_timedelta64_to_float(td, datetime_unit=time_unit)
1060 np.testing.assert_allclose(out, expected)
1061 assert isinstance(out, float)
1062
1063 out = np_timedelta64_to_float(np.atleast_1d(td), datetime_unit=time_unit)
1064 np.testing.assert_allclose(out, expected)
1065
1066
1067@pytest.mark.parametrize("np_dt_unit", ["D", "h", "m", "s", "ms", "us", "ns"])

Callers

nothing calls this directly

Calls 1

np_timedelta64_to_floatFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…