Skip to content

Commit dd95dbb

Browse files
committed
add type annotations for adaptive/learner/integrator_coeffs.py
1 parent a0895e4 commit dd95dbb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

adaptive/learner/integrator_coeffs.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
from collections import defaultdict
44
from fractions import Fraction
5+
from typing import List, Tuple
56

67
import numpy as np
78
import scipy.linalg
9+
from numpy import ndarray
810

911

10-
def legendre(n):
12+
def legendre(n: int) -> List[List[Fraction]]:
1113
"""Return the first n Legendre polynomials.
1214
1315
The polynomials have *standard* normalization, i.e.
@@ -28,7 +30,7 @@ def legendre(n):
2830
return result
2931

3032

31-
def newton(n):
33+
def newton(n: int) -> ndarray:
3234
"""Compute the monomial coefficients of the Newton polynomial over the
3335
nodes of the n-point Clenshaw-Curtis quadrature rule.
3436
"""
@@ -85,7 +87,7 @@ def newton(n):
8587
return cf
8688

8789

88-
def scalar_product(a, b):
90+
def scalar_product(a: List[Fraction], b: List[Fraction]) -> Fraction:
8991
"""Compute the polynomial scalar product int_-1^1 dx a(x) b(x).
9092
9193
The args must be sequences of polynomial coefficients. This
@@ -106,7 +108,7 @@ def scalar_product(a, b):
106108
return 2 * sum(c[i] / (i + 1) for i in range(0, lc, 2))
107109

108110

109-
def calc_bdef(ns):
111+
def calc_bdef(ns: Tuple[int, int, int, int]) -> List[ndarray]:
110112
"""Calculate the decompositions of Newton polynomials (over the nodes
111113
of the n-point Clenshaw-Curtis quadrature rule) in terms of
112114
Legandre polynomials.
@@ -132,7 +134,7 @@ def calc_bdef(ns):
132134
return result
133135

134136

135-
def calc_V(x, n):
137+
def calc_V(x: ndarray, n: int) -> ndarray:
136138
V = [np.ones(x.shape), x.copy()]
137139
for i in range(2, n):
138140
V.append((2 * i - 1) / i * x * V[-1] - (i - 1) / i * V[-2])

0 commit comments

Comments
 (0)