(
np_dt_unit: NPDatetimeUnitOptions, time_unit: PDDatetimeUnitOptions
)
| 1049 | |
| 1050 | @pytest.mark.parametrize("np_dt_unit", ["D", "h", "m", "s", "ms", "us", "ns"]) |
| 1051 | def 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"]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…