From 4d4c0172e96c6650d09f01381cd4ee6f8e6f2426 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:04:39 +0530 Subject: [PATCH] Fix floating point imprecision with `np.timedelta64` --- pandas/tests/io/sas/test_sas7bdat.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/tests/io/sas/test_sas7bdat.py b/pandas/tests/io/sas/test_sas7bdat.py index 889ef61740a2c..69fed85763ca5 100644 --- a/pandas/tests/io/sas/test_sas7bdat.py +++ b/pandas/tests/io/sas/test_sas7bdat.py @@ -7,7 +7,7 @@ import numpy as np import pytest -from pandas.compat import IS64 +from pandas.compat import IS64, WASM from pandas.errors import EmptyDataError import pandas as pd @@ -190,7 +190,7 @@ def test_date_time(datapath): res = df0["DateTimeHi"].astype("M8[us]").dt.round("ms") df0["DateTimeHi"] = res.astype("M8[ms]") - if not IS64: + if (not IS64) or (WASM): # No good reason for this, just what we get on the CI df0.loc[0, "DateTimeHi"] += np.timedelta64(1, "ms") df0.loc[[2, 3], "DateTimeHi"] -= np.timedelta64(1, "ms") @@ -285,7 +285,7 @@ def test_max_sas_date(datapath): columns=["text", "dt_as_float", "dt_as_dt", "date_as_float", "date_as_date"], ) - if not IS64: + if (not IS64) or (WASM): # No good reason for this, just what we get on the CI expected.loc[:, "dt_as_dt"] -= np.timedelta64(1, "ms") @@ -328,7 +328,7 @@ def test_max_sas_date_iterator(datapath): columns=col_order, ), ] - if not IS64: + if (not IS64) or (WASM): # No good reason for this, just what we get on the CI expected[0].loc[0, "dt_as_dt"] -= np.timedelta64(1, "ms") expected[1].loc[0, "dt_as_dt"] -= np.timedelta64(1, "ms") @@ -359,7 +359,7 @@ def test_null_date(datapath): ), }, ) - if not IS64: + if (not IS64) or (WASM): # No good reason for this, just what we get on the CI expected.loc[0, "datetimecol"] -= np.timedelta64(1, "ms") tm.assert_frame_equal(df, expected)