@@ -134,7 +134,9 @@ def test_extrapolation_methods(linear_func):
134
134
assert np .isclose (linear_func .getValue (- 1 ), - 1 , atol = 1e-6 )
135
135
136
136
137
- def test_integral_linear_interpolation (linear_func ):
137
+ @pytest .mark .parametrize ("a" , [- 1 , 0 , 0.5 , 1 , 2 , 2.5 , 3.5 , 4 , 5 ])
138
+ @pytest .mark .parametrize ("b" , [- 1 , 0 , 0.5 , 1 , 2 , 2.5 , 3.5 , 4 , 5 ])
139
+ def test_integral_linear_interpolation (linearly_interpolated_func , a , b ):
138
140
"""Test the integral method of the Function class.
139
141
140
142
Parameters
@@ -143,12 +145,17 @@ def test_integral_linear_interpolation(linear_func):
143
145
A Function object created from a list of values.
144
146
"""
145
147
# Test integral
146
- assert np .isclose (linear_func .integral (0 , 1 ), 0.5 , atol = 1e-6 )
148
+ assert np .isclose (
149
+ linearly_interpolated_func .integral (a , b , numerical = False ),
150
+ linearly_interpolated_func .integral (a , b , numerical = True ),
151
+ atol = 1e-3 ,
152
+ )
147
153
148
154
149
- @pytest .mark .parametrize ("a" , [- 1 , 0 , 0.5 , 1 , 2 , 2.5 , 3.5 , 4 , 5 ])
150
- @pytest .mark .parametrize ("b" , [- 1 , 0 , 0.5 , 1 , 2 , 2.5 , 3.5 , 4 , 5 ])
151
- def test_integral_spline_interpolation (spline_func , a , b ):
155
+ @pytest .mark .parametrize ("func" , ["linear_func" , "spline_interpolated_func" ])
156
+ @pytest .mark .parametrize ("a" , [- 1 , - 0.5 , 0 , 0.5 , 1 , 2 , 2.5 , 3.5 , 4 , 5 ])
157
+ @pytest .mark .parametrize ("b" , [- 1 , - 0.5 , 0 , 0.5 , 1 , 2 , 2.5 , 3.5 , 4 , 5 ])
158
+ def test_integral_spline_interpolation (request , func , a , b ):
152
159
"""Test the integral method of the Function class.
153
160
154
161
Parameters
@@ -161,8 +168,10 @@ def test_integral_spline_interpolation(spline_func, a, b):
161
168
Upper limit of the integral.
162
169
"""
163
170
# Test integral
171
+ # Get the function from the fixture
172
+ func = request .getfixturevalue (func )
164
173
assert np .isclose (
165
- spline_func .integral (a , b , numerical = False ),
166
- spline_func .integral (a , b , numerical = True ),
174
+ func .integral (a , b , numerical = False ),
175
+ func .integral (a , b , numerical = True ),
167
176
atol = 1e-3 ,
168
177
)
0 commit comments