@@ -32,6 +32,30 @@ def test_borefield_init(field, request):
3232 H , D , r_b , x , y , tilt = tilt , orientation = orientation )
3333 assert borefield == borefield_from_boreholes
3434
35+
36+ # Test Borefield.__add__ and Borefield.__radd__
37+ @pytest .mark .parametrize ("field, other_field, field_list, other_field_list" , [
38+ # Using Borefield and Borehole objects
39+ ('single_borehole' , 'two_boreholes_inclined' , False , False ),
40+ ('ten_boreholes_rectangular' , 'single_borehole_short' , False , False ),
41+ ('ten_boreholes_rectangular' , 'two_boreholes_inclined' , False , False ),
42+ # Using Borefield as lists
43+ ('ten_boreholes_rectangular' , 'two_boreholes_inclined' , False , True ),
44+ ('ten_boreholes_rectangular' , 'two_boreholes_inclined' , True , False ),
45+ ])
46+ def test_borefield_add (field , other_field , field_list , other_field_list , request ):
47+ field = request .field
48+ other_field = request .other_field
49+ reference_field = gt .borefield .Borefield .from_boreholes (
50+ field .to_boreholes () + other_field .to_boreholes ()
51+ )
52+ if field_list :
53+ field = field .to_boreholes ()
54+ if other_field_list :
55+ other_field = other_field .to_boreholes ()
56+ assert field + other_field_list == reference_field
57+
58+
3559# Test borefield comparison using __eq__
3660@pytest .mark .parametrize ("field, other_field, expected" , [
3761 # Fields that are equal
@@ -53,6 +77,7 @@ def test_borefield_eq(field, other_field, expected, request):
5377 other_field = request .getfixturevalue (other_field )
5478 assert (borefield == other_field ) == expected
5579
80+
5681# Test borefield comparison using __ne__
5782@pytest .mark .parametrize ("field, other_field, expected" , [
5883 # Fields that are equal
@@ -75,16 +100,6 @@ def test_borefield_ne(field, other_field, expected, request):
75100 assert (borefield != other_field ) == expected
76101
77102
78- def test_borefield_add ():
79- borehole = gt .boreholes .Borehole (100 , 1 , 0.075 , 15 , 10 )
80- borefield = gt .borefield .Borefield .rectangle_field (2 , 1 , 6 , 6 , 100 , 1 , 0.075 )
81- borefield_2 = gt .borefield .Borefield .from_boreholes ([borehole , gt .boreholes .Borehole (110 , 1 , 0.075 , 20 , 15 )])
82- assert borefield + borehole == gt .borefield .Borefield .from_boreholes (borefield .to_boreholes () + [borehole ])
83- assert borehole + borefield == gt .borefield .Borefield .from_boreholes (borefield .to_boreholes () + [borehole ])
84- assert borefield + [borehole ] == gt .borefield .Borefield .from_boreholes (borefield .to_boreholes () + [borehole ])
85- assert borefield + borefield_2 == gt .borefield .Borefield .from_boreholes (borefield .to_boreholes ()+ borefield_2 .to_boreholes ())
86-
87-
88103# =============================================================================
89104# Test evaluate_g_function (vertical boreholes)
90105# =============================================================================
0 commit comments