(x: DataArray)
| 938 | return type(scalar)(1970, 1, 1) |
| 939 | |
| 940 | def to_floatable(x: DataArray) -> DataArray: |
| 941 | if x.dtype.kind in "MO": |
| 942 | # datetimes (CFIndexes are object type) |
| 943 | offset = ( |
| 944 | np.datetime64("1970-01-01") if x.dtype.kind == "M" else _cfoffset(x) |
| 945 | ) |
| 946 | return x.copy( |
| 947 | data=datetime_to_numeric(x.data, offset=offset, datetime_unit="ns"), |
| 948 | ) |
| 949 | elif x.dtype.kind == "m": |
| 950 | # timedeltas |
| 951 | return duck_array_ops.astype(x, dtype=float) |
| 952 | return x |
| 953 | |
| 954 | if isinstance(data, Dataset): |
| 955 | return data.map(to_floatable) |
no test coverage detected
searching dependent graphs…