Coverage for C:\src\imod-python\imod\testing.py: 100%

1 import numpy as np

2 import pandas as pd

3

4

5 def assert_frame_equal(left: pd.DataFrame, right: pd.DataFrame, **kwargs):

6 """

7 Dataframes are regularly created with "platform dependent" integer columns,

8 such as int and np.intp; windows behaves differently from linux. This

9 creates issues with local testing versus CI. Type checking can be disabled

10 in assert_frame_equal, but we would like to check float versus int versus

11 string -- we just convert any integer to 64-bit here.

12

13 https://pandas.pydata.org/docs/reference/api/pandas.testing.assert_frame_equal.html

14 """

15

16 def always_int64(df):

17 df = df.copy()

18 for column, dtype in df.dtypes.items():

19 if np.issubdtype(dtype, np.integer):

20 df[column] = df[column].astype(np.int64)

21 return df

22

23 left = always_int64(left)

24 right = always_int64(right)

25 pd.testing.assert_frame_equal(left, right, **kwargs)