@@ -22,7 +22,7 @@ def test_serialization():
22
22
assert_session_equal (session , session2 )
23
23
24
24
25
- def assert_equal (obj1 , obj2 ):
25
+ def assert_equal (obj1 , obj2 ) -> None :
26
26
"""Check if two objects are equal."""
27
27
if isinstance (obj1 , pydantic .BaseModel ):
28
28
assert isinstance (obj2 , pydantic .BaseModel )
@@ -37,9 +37,16 @@ def assert_equal(obj1, obj2):
37
37
for i in range (len (obj1 )):
38
38
assert_equal (obj1 [i ], obj2 [i ])
39
39
elif isinstance (obj1 , pd .DataFrame ):
40
+ assert isinstance (obj2 , pd .DataFrame )
41
+ if obj1 .empty and obj2 .empty :
42
+ # if both are empty, we don't compare columns
43
+ return
40
44
pd .testing .assert_frame_equal (obj1 , obj2 , check_dtype = False )
41
45
elif isinstance (obj1 , pd .Series ):
42
- pd .testing .assert_series_equal (obj1 , obj2 )
46
+ assert isinstance (obj2 , pd .Series ), f"{ obj1 } != { obj2 } "
47
+ pd .testing .assert_series_equal (
48
+ obj1 , obj2 , atol = 1e-14 , rtol = 1e-14 , check_dtype = False
49
+ )
43
50
elif isinstance (obj1 , np .ndarray ):
44
51
np .testing .assert_almost_equal (obj1 , obj2 )
45
52
elif isinstance (obj1 , float ) and pd .isna (obj1 ):
0 commit comments