3
3
4
4
from collections import defaultdict
5
5
from fractions import Fraction
6
- from functools import partial
7
6
from typing import Callable , List , Tuple , Union
8
7
9
8
import numpy as np
@@ -247,7 +246,7 @@ def points(self) -> np.ndarray:
247
246
248
247
@classmethod
249
248
def make_first (
250
- cls , f : Union [ partial , Callable ] , a : int , b : int , depth : int = 2
249
+ cls , f : Callable , a : int , b : int , depth : int = 2
251
250
) -> Tuple ["_Interval" , int ]:
252
251
ival = _Interval (a , b , depth , 1 )
253
252
fx = f (ival .points ())
@@ -269,7 +268,7 @@ def calc_igral_and_err(self, c_old: np.ndarray) -> float:
269
268
return c_diff
270
269
271
270
def split (
272
- self , f : Union [ partial , Callable ]
271
+ self , f : Callable
273
272
) -> Union [Tuple [Tuple [float , float , float ], int ], Tuple [List ["_Interval" ], int ]]:
274
273
m = (self .a + self .b ) / 2
275
274
f_center = self .fx [(len (self .fx ) - 1 ) // 2 ]
@@ -295,7 +294,7 @@ def split(
295
294
296
295
return ivals , nr_points
297
296
298
- def refine (self , f : Union [ partial , Callable ] ) -> Tuple [np .ndarray , bool , int ]:
297
+ def refine (self , f : Callable ) -> Tuple [np .ndarray , bool , int ]:
299
298
"""Increase degree of interval."""
300
299
self .depth = depth = self .depth + 1
301
300
points = self .points ()
@@ -308,7 +307,7 @@ def refine(self, f: Union[partial, Callable]) -> Tuple[np.ndarray, bool, int]:
308
307
309
308
310
309
def algorithm_4 (
311
- f : Union [ partial , Callable ] , a : int , b : int , tol : float , N_loops : int = int (1e9 )
310
+ f : Callable , a : int , b : int , tol : float , N_loops : int = int (1e9 )
312
311
) -> Tuple [float , float , int , List ["_Interval" ]]:
313
312
"""ALGORITHM_4 evaluates an integral using adaptive quadrature. The
314
313
algorithm uses Clenshaw-Curtis quadrature rules of increasing
0 commit comments