(time_unit: PDDatetimeUnitOptions)
| 2183 | |
| 2184 | |
| 2185 | def test_roundtrip_0size_timedelta(time_unit: PDDatetimeUnitOptions) -> None: |
| 2186 | # regression test for GitHub issue #10310 |
| 2187 | encoding = {"units": "days", "dtype": np.dtype("int64")} |
| 2188 | data = np.array([], dtype=f"=m8[{time_unit}]") |
| 2189 | decoded = Variable(["time"], data, encoding=encoding) |
| 2190 | encoded = conventions.encode_cf_variable(decoded, name="foo") |
| 2191 | assert encoded.dtype == encoding["dtype"] |
| 2192 | assert encoded.attrs["units"] == encoding["units"] |
| 2193 | decoded = conventions.decode_cf_variable("foo", encoded, decode_timedelta=True) |
| 2194 | assert decoded.dtype == np.dtype(f"=m8[{time_unit}]") |
| 2195 | with assert_no_warnings(): |
| 2196 | decoded.load() |
| 2197 | assert decoded.dtype == np.dtype("=m8[s]") |
| 2198 | assert decoded.encoding == encoding |
| 2199 | |
| 2200 | |
| 2201 | def test_roundtrip_empty_datetime64_array(time_unit: PDDatetimeUnitOptions) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…