Coverage for C:\src\imod-python\imod\testing.py: 100%
12 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-08 14:15 +0200
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-08 14:15 +0200
1import numpy as np
2import pandas as pd
5def 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.
13 https://pandas.pydata.org/docs/reference/api/pandas.testing.assert_frame_equal.html
14 """
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
23 left = always_int64(left)
24 right = always_int64(right)
25 pd.testing.assert_frame_equal(left, right, **kwargs)