77import pytest
88
99from diffly ._conditions import _can_compare_dtypes , condition_equal_columns
10+ from diffly .comparison import compare_frames
1011
1112
1213def test_condition_equal_columns_struct () -> None :
1314 # Arrange
1415 lhs = pl .DataFrame (
1516 {
1617 "pk" : [1 , 2 ],
17- "a_left " : [{"x" : 1.0 , "y" : 2.0 }, {"x" : 2.0 , "y" : 2.1 }],
18+ "a " : [{"x" : 1.0 , "y" : 2.0 }, {"x" : 2.0 , "y" : 2.1 }],
1819 }
1920 )
2021 rhs = pl .DataFrame (
2122 {
2223 "pk" : [1 , 2 ],
23- "a_right " : [{"y" : 2.0 , "x" : 1.1 }, {"y" : 2.7 , "x" : 2.1 }],
24+ "a " : [{"y" : 2.0 , "x" : 1.1 }, {"y" : 2.7 , "x" : 2.1 }],
2425 }
2526 )
2627
28+ c = compare_frames (lhs , rhs , primary_key = "pk" , abs_tol = 0.5 , rel_tol = 0 )
29+ assert c ._max_list_lengths_by_column == {}
30+
2731 # Act
32+ lhs = lhs .rename ({"a" : "a_left" })
33+ rhs = rhs .rename ({"a" : "a_right" })
2834 actual = (
2935 lhs .join (rhs , on = "pk" , maintain_order = "left" )
3036 .select (
@@ -33,8 +39,8 @@ def test_condition_equal_columns_struct() -> None:
3339 dtype_left = lhs .schema ["a_left" ],
3440 dtype_right = rhs .schema ["a_right" ],
3541 max_list_length = None ,
36- abs_tol = 0.5 ,
37- rel_tol = 0 ,
42+ abs_tol = c . abs_tol_by_column [ "a" ] ,
43+ rel_tol = c . rel_tol_by_column [ "a" ] ,
3844 )
3945 )
4046 .to_series ()
0 commit comments