44 integrate_discrete_squared_curvature ,
55)
66import pytest
7+ from typing import Literal
78
89
910def test_forward_euler_uniform_spacing ():
@@ -191,6 +192,7 @@ def test_sinusoidal_integration_accuracy():
191192 ### Exact integral of sin(x) from 0 to 2*pi is 0
192193 expected = 0.0
193194
195+ method : Literal ["trapezoidal" , "forward_simpson" , "backward_simpson" , "cubic" ]
194196 for method in ["trapezoidal" , "forward_simpson" , "backward_simpson" , "cubic" ]:
195197 result = integrate_discrete_intervals (f , x , method = method )
196198 integral = np .sum (result )
@@ -220,6 +222,7 @@ def test_squared_curvature_sine_wave():
220222 ### Integral of sin^2(x) from 0 to 2*pi is pi
221223 expected = np .pi
222224
225+ method : Literal ["cubic" , "simpson" , "hybrid_simpson_cubic" ]
223226 for method in ["cubic" , "simpson" , "hybrid_simpson_cubic" ]:
224227 result = integrate_discrete_squared_curvature (f , x , method = method )
225228 integral = np .sum (result )
@@ -237,6 +240,7 @@ def test_squared_curvature_parabola():
237240 ### Integral of 4 from 0 to 10 is 40
238241 expected = 40.0
239242
243+ method : Literal ["cubic" , "simpson" , "hybrid_simpson_cubic" ]
240244 for method in ["cubic" , "simpson" , "hybrid_simpson_cubic" ]:
241245 result = integrate_discrete_squared_curvature (f , x , method = method )
242246 integral = np .sum (result )
@@ -254,6 +258,7 @@ def test_squared_curvature_cubic():
254258 ### Integral of 36x^2 from 0 to 5 is 36 * [x^3/3]_0^5 = 36 * 125/3 = 1500
255259 expected = 1500.0
256260
261+ method : Literal ["cubic" , "simpson" , "hybrid_simpson_cubic" ]
257262 for method in ["cubic" , "simpson" , "hybrid_simpson_cubic" ]:
258263 result = integrate_discrete_squared_curvature (f , x , method = method )
259264 integral = np .sum (result )
@@ -268,7 +273,7 @@ def test_invalid_method_raises_error():
268273 f = x ** 2
269274
270275 with pytest .raises (ValueError ):
271- integrate_discrete_intervals (f , x , method = "invalid_method" )
276+ integrate_discrete_intervals (f , x , method = "invalid_method" ) # type: ignore[arg-type]
272277
273278
274279def test_invalid_method_endpoints_raises_error ():
@@ -278,7 +283,7 @@ def test_invalid_method_endpoints_raises_error():
278283
279284 with pytest .raises (ValueError ):
280285 integrate_discrete_intervals (
281- f , x , method = "cubic" , method_endpoints = "invalid_endpoint_method"
286+ f , x , method = "cubic" , method_endpoints = "invalid_endpoint_method" # type: ignore[arg-type]
282287 )
283288
284289
@@ -297,7 +302,7 @@ def test_invalid_squared_curvature_method():
297302 f = x ** 2
298303
299304 with pytest .raises (ValueError ):
300- integrate_discrete_squared_curvature (f , x , method = "invalid_method" )
305+ integrate_discrete_squared_curvature (f , x , method = "invalid_method" ) # type: ignore[arg-type]
301306
302307
303308def test_midpoint_deprecation_warning ():
@@ -306,7 +311,7 @@ def test_midpoint_deprecation_warning():
306311 f = x ** 2
307312
308313 with pytest .raises (PendingDeprecationWarning ):
309- integrate_discrete_intervals (f , x , method = "midpoint" )
314+ integrate_discrete_intervals (f , x , method = "midpoint" ) # type: ignore[arg-type]
310315
311316
312317def test_all_method_aliases ():
@@ -317,25 +322,25 @@ def test_all_method_aliases():
317322 ### Test forward Euler aliases
318323 result_forward = integrate_discrete_intervals (f , x , method = "forward_euler" )
319324 for alias in ["forward" , "euler_forward" , "left" , "left_riemann" ]:
320- result_alias = integrate_discrete_intervals (f , x , method = alias )
325+ result_alias = integrate_discrete_intervals (f , x , method = alias ) # type: ignore[arg-type]
321326 assert np .allclose (result_forward , result_alias )
322327
323328 ### Test backward Euler aliases
324329 result_backward = integrate_discrete_intervals (f , x , method = "backward_euler" )
325330 for alias in ["backward" , "euler_backward" , "right" , "right_riemann" ]:
326- result_alias = integrate_discrete_intervals (f , x , method = alias )
331+ result_alias = integrate_discrete_intervals (f , x , method = alias ) # type: ignore[arg-type]
327332 assert np .allclose (result_backward , result_alias )
328333
329334 ### Test trapezoidal aliases
330335 result_trapz = integrate_discrete_intervals (f , x , method = "trapezoidal" )
331336 for alias in ["trapezoid" , "trapz" ]:
332- result_alias = integrate_discrete_intervals (f , x , method = alias )
337+ result_alias = integrate_discrete_intervals (f , x , method = alias ) # type: ignore[arg-type]
333338 assert np .allclose (result_trapz , result_alias )
334339
335340 ### Test Simpson aliases
336341 result_simpson = integrate_discrete_intervals (f , x , method = "forward_simpson" )
337342 for alias in ["simpson_forward" , "simpson" ]:
338- result_alias = integrate_discrete_intervals (f , x , method = alias )
343+ result_alias = integrate_discrete_intervals (f , x , method = alias ) # type: ignore[arg-type]
339344 assert np .allclose (result_simpson , result_alias )
340345
341346
@@ -344,6 +349,7 @@ def test_zero_function():
344349 x = np .linspace (0 , 10 , 50 )
345350 f = np .zeros_like (x )
346351
352+ method : Literal ["trapezoidal" , "forward_simpson" , "backward_simpson" , "cubic" ]
347353 for method in ["trapezoidal" , "forward_simpson" , "backward_simpson" , "cubic" ]:
348354 result = integrate_discrete_intervals (f , x , method = method )
349355 assert np .allclose (result , 0.0 )
0 commit comments