From 974c4f75eb66fa6fddcf505c5cdab69a4e0ddcde Mon Sep 17 00:00:00 2001 From: Sujeito Operator Date: Fri, 14 Aug 2026 10:25:48 +0200 Subject: [PATCH] Avoid the deprecated generic timedelta unit in test_subsecond_outputdt elapsed_t and expected_t are timedelta64[ms] arrays, and assert_allclose evaluates `atol + rtol * abs(y)` internally, so the bare integer atol was being added to a timedelta64 -- numpy's deprecated 'generic' unit, which its own warning says will raise an error in a future release. Compare the millisecond counts as int64 instead, which keeps the 1-millisecond tolerance exactly rather than reinterpreting it. Contributes to #2682. --- tests/test_particlefile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_particlefile.py b/tests/test_particlefile.py index 9ba7836ac..671252dea 100755 --- a/tests/test_particlefile.py +++ b/tests/test_particlefile.py @@ -359,7 +359,10 @@ def Update_lon(particles, fieldset): # pragma: no cover np.testing.assert_allclose(df["x"], np.arange(0, 1 + 1e-6, dt / 1000.0), atol=1e-6) expected_t = np.arange(0, 1001, dt).astype("timedelta64[ms]") elapsed_t = (df["t"] - df["t"].min()).to_numpy().astype("timedelta64[ms]") - np.testing.assert_allclose(elapsed_t, expected_t, atol=1) + # Compare the millisecond counts rather than the timedelta64 arrays themselves: + # assert_allclose evaluates `atol + rtol * abs(y)`, and adding the bare integer + # atol to a timedelta64 relies on the deprecated 'generic' timedelta unit. + np.testing.assert_allclose(elapsed_t.astype("int64"), expected_t.astype("int64"), atol=1) def test_correct_misaligned_outputdt_dt(fieldset, tmp_parquet):