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

Function test_pd_timedelta_to_float

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

Source from the content-addressed store, hash-verified

1066
1067@pytest.mark.parametrize("np_dt_unit", ["D", "h", "m", "s", "ms", "us", "ns"])
1068def test_pd_timedelta_to_float(
1069 np_dt_unit: NPDatetimeUnitOptions, time_unit: PDDatetimeUnitOptions
1070):
1071 # tests any combination of source pd.Timedelta (NPDatetimeUnitOptions) with
1072 # np_timedelta_to_float with dedicated target unit (PDDatetimeUnitOptions)
1073 td = pd.Timedelta(1, np_dt_unit)
1074 expected = _NS_PER_TIME_DELTA[np_dt_unit] / _NS_PER_TIME_DELTA[time_unit]
1075
1076 out = pd_timedelta_to_float(td, datetime_unit=time_unit)
1077 np.testing.assert_allclose(out, expected)
1078 assert isinstance(out, float)
1079
1080
1081@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 1

pd_timedelta_to_floatFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…