Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions xarray/tests/test_coding_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,19 @@
np.testing.assert_equal(actual, expected)


def test_roundtrip_float32_datetime():
expected = np.array([1867128, 1867134, 1867140], dtype="float32")
units = "hours since 1800-01-01"
calendar = "standard"

arr = decode_cf_datetime(expected, units=units, calendar=calendar, use_cftime=False)
actual, _, _ = encode_cf_datetime(
arr, units=units, calendar=calendar, dtype=expected.dtype
)
np.testing.assert_equal(actual, expected)
assert actual.dtype == expected.dtype

Check failure on line 1317 in xarray/tests/test_coding_times.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.10 bare-minimum

test_roundtrip_float32_datetime AssertionError: assert dtype('float64') == dtype('float32') + where dtype('float64') = array([1867128., 1867134., 1867140.]).dtype + and dtype('float32') = array([1867128., 1867134., 1867140.], dtype=float32).dtype

Check failure on line 1317 in xarray/tests/test_coding_times.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.12 all-but-dask

test_roundtrip_float32_datetime AssertionError: assert dtype('float64') == dtype('float32') + where dtype('float64') = array([1867128., 1867134., 1867140.]).dtype + and dtype('float32') = array([1867128., 1867134., 1867140.], dtype=float32).dtype

Check failure on line 1317 in xarray/tests/test_coding_times.py

View workflow job for this annotation

GitHub Actions / macos-latest py3.13

test_roundtrip_float32_datetime AssertionError: assert dtype('float64') == dtype('float32') + where dtype('float64') = array([1867128., 1867134., 1867140.]).dtype + and dtype('float32') = array([1867128., 1867134., 1867140.], dtype=float32).dtype

Check failure on line 1317 in xarray/tests/test_coding_times.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.13 all-but-numba

test_roundtrip_float32_datetime AssertionError: assert dtype('float64') == dtype('float32') + where dtype('float64') = array([1867128., 1867134., 1867140.]).dtype + and dtype('float32') = array([1867128., 1867134., 1867140.], dtype=float32).dtype

Check failure on line 1317 in xarray/tests/test_coding_times.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.10

test_roundtrip_float32_datetime AssertionError: assert dtype('float64') == dtype('float32') + where dtype('float64') = array([1867128., 1867134., 1867140.]).dtype + and dtype('float32') = array([1867128., 1867134., 1867140.], dtype=float32).dtype

Check failure on line 1317 in xarray/tests/test_coding_times.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.10 min-all-deps

test_roundtrip_float32_datetime AssertionError: assert dtype('float64') == dtype('float32') + where dtype('float64') = array([1867128., 1867134., 1867140.]).dtype + and dtype('float32') = array([1867128., 1867134., 1867140.], dtype=float32).dtype

Check failure on line 1317 in xarray/tests/test_coding_times.py

View workflow job for this annotation

GitHub Actions / macos-latest py3.10

test_roundtrip_float32_datetime AssertionError: assert dtype('float64') == dtype('float32') + where dtype('float64') = array([1867128., 1867134., 1867140.]).dtype + and dtype('float32') = array([1867128., 1867134., 1867140.], dtype=float32).dtype

Check failure on line 1317 in xarray/tests/test_coding_times.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.13

test_roundtrip_float32_datetime AssertionError: assert dtype('float64') == dtype('float32') + where dtype('float64') = array([1867128., 1867134., 1867140.]).dtype + and dtype('float32') = array([1867128., 1867134., 1867140.], dtype=float32).dtype


@pytest.mark.parametrize("time_unit", ["ms", "us", "ns"])
def test_decode_float_datetime_with_decimals(
time_unit: PDDatetimeUnitOptions,
Expand Down
Loading