Skip to content

Commit 695df25

Browse files
author
Bas van Beek
committed
ENH: Add improved placeholder annotations for np.polynomial
1 parent 13b30e9 commit 695df25

File tree

9 files changed

+370
-8
lines changed

9 files changed

+370
-8
lines changed

numpy/polynomial/__init__.pyi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, List
1+
from typing import List
22

33
from numpy.polynomial import (
44
chebyshev as chebyshev,
@@ -8,13 +8,13 @@ from numpy.polynomial import (
88
legendre as legendre,
99
polynomial as polynomial,
1010
)
11+
from numpy.polynomial.chebyshev import Chebyshev as Chebyshev
12+
from numpy.polynomial.hermite import Hermite as Hermite
13+
from numpy.polynomial.hermite_e import HermiteE as HermiteE
14+
from numpy.polynomial.laguerre import Laguerre as Laguerre
15+
from numpy.polynomial.legendre import Legendre as Legendre
16+
from numpy.polynomial.polynomial import Polynomial as Polynomial
1117

1218
__all__: List[str]
1319

14-
Polynomial: Any
15-
Chebyshev: Any
16-
Legendre: Any
17-
Hermite: Any
18-
HermiteE: Any
19-
Laguerre: Any
20-
set_default_printstyle: Any
20+
def set_default_printstyle(style): ...

numpy/polynomial/_polybase.pyi

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import abc
2+
from typing import Any, List, ClassVar
3+
4+
__all__: List[str]
5+
6+
class ABCPolyBase(abc.ABC):
7+
__hash__: ClassVar[None] # type: ignore[assignment]
8+
__array_ufunc__: ClassVar[None]
9+
maxpower: ClassVar[int]
10+
coef: Any
11+
@property
12+
@abc.abstractmethod
13+
def domain(self): ...
14+
@property
15+
@abc.abstractmethod
16+
def window(self): ...
17+
@property
18+
@abc.abstractmethod
19+
def basis_name(self): ...
20+
def has_samecoef(self, other): ...
21+
def has_samedomain(self, other): ...
22+
def has_samewindow(self, other): ...
23+
def has_sametype(self, other): ...
24+
def __init__(self, coef, domain=..., window=...): ...
25+
def __format__(self, fmt_str): ...
26+
def __call__(self, arg): ...
27+
def __iter__(self): ...
28+
def __len__(self): ...
29+
def __neg__(self): ...
30+
def __pos__(self): ...
31+
def __add__(self, other): ...
32+
def __sub__(self, other): ...
33+
def __mul__(self, other): ...
34+
def __truediv__(self, other): ...
35+
def __floordiv__(self, other): ...
36+
def __mod__(self, other): ...
37+
def __divmod__(self, other): ...
38+
def __pow__(self, other): ...
39+
def __radd__(self, other): ...
40+
def __rsub__(self, other): ...
41+
def __rmul__(self, other): ...
42+
def __rdiv__(self, other): ...
43+
def __rtruediv__(self, other): ...
44+
def __rfloordiv__(self, other): ...
45+
def __rmod__(self, other): ...
46+
def __rdivmod__(self, other): ...
47+
def __eq__(self, other): ...
48+
def __ne__(self, other): ...
49+
def copy(self): ...
50+
def degree(self): ...
51+
def cutdeg(self, deg): ...
52+
def trim(self, tol=...): ...
53+
def truncate(self, size): ...
54+
def convert(self, domain=..., kind=..., window=...): ...
55+
def mapparms(self): ...
56+
def integ(self, m=..., k = ..., lbnd=...): ...
57+
def deriv(self, m=...): ...
58+
def roots(self): ...
59+
def linspace(self, n=..., domain=...): ...
60+
@classmethod
61+
def fit(cls, x, y, deg, domain=..., rcond=..., full=..., w=..., window=...): ...
62+
@classmethod
63+
def fromroots(cls, roots, domain = ..., window=...): ...
64+
@classmethod
65+
def identity(cls, domain=..., window=...): ...
66+
@classmethod
67+
def basis(cls, deg, domain=..., window=...): ...
68+
@classmethod
69+
def cast(cls, series, domain=..., window=...): ...

numpy/polynomial/chebyshev.pyi

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from typing import Any, List
2+
3+
from numpy import ndarray, dtype, int_
4+
from numpy.polynomial._polybase import ABCPolyBase
5+
from numpy.polynomial.polyutils import trimcoef
6+
7+
__all__: List[str]
8+
9+
chebtrim = trimcoef
10+
11+
def poly2cheb(pol): ...
12+
def cheb2poly(c): ...
13+
14+
chebdomain: ndarray[Any, dtype[int_]]
15+
chebzero: ndarray[Any, dtype[int_]]
16+
chebone: ndarray[Any, dtype[int_]]
17+
chebx: ndarray[Any, dtype[int_]]
18+
19+
def chebline(off, scl): ...
20+
def chebfromroots(roots): ...
21+
def chebadd(c1, c2): ...
22+
def chebsub(c1, c2): ...
23+
def chebmulx(c): ...
24+
def chebmul(c1, c2): ...
25+
def chebdiv(c1, c2): ...
26+
def chebpow(c, pow, maxpower=...): ...
27+
def chebder(c, m=..., scl=..., axis=...): ...
28+
def chebint(c, m=..., k = ..., lbnd=..., scl=..., axis=...): ...
29+
def chebval(x, c, tensor=...): ...
30+
def chebval2d(x, y, c): ...
31+
def chebgrid2d(x, y, c): ...
32+
def chebval3d(x, y, z, c): ...
33+
def chebgrid3d(x, y, z, c): ...
34+
def chebvander(x, deg): ...
35+
def chebvander2d(x, y, deg): ...
36+
def chebvander3d(x, y, z, deg): ...
37+
def chebfit(x, y, deg, rcond=..., full=..., w=...): ...
38+
def chebcompanion(c): ...
39+
def chebroots(c): ...
40+
def chebinterpolate(func, deg, args = ...): ...
41+
def chebgauss(deg): ...
42+
def chebweight(x): ...
43+
def chebpts1(npts): ...
44+
def chebpts2(npts): ...
45+
46+
class Chebyshev(ABCPolyBase):
47+
@classmethod
48+
def interpolate(cls, func, deg, domain=..., args = ...): ...
49+
domain: Any
50+
window: Any
51+
basis_name: Any

numpy/polynomial/hermite.pyi

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from typing import Any, List
2+
3+
from numpy import ndarray, dtype, int_, float_
4+
from numpy.polynomial._polybase import ABCPolyBase
5+
from numpy.polynomial.polyutils import trimcoef
6+
7+
__all__: list[str]
8+
9+
hermtrim = trimcoef
10+
11+
def poly2herm(pol): ...
12+
def herm2poly(c): ...
13+
14+
hermdomain: ndarray[Any, dtype[int_]]
15+
hermzero: ndarray[Any, dtype[int_]]
16+
hermone: ndarray[Any, dtype[int_]]
17+
hermx: ndarray[Any, dtype[float_]]
18+
19+
def hermline(off, scl): ...
20+
def hermfromroots(roots): ...
21+
def hermadd(c1, c2): ...
22+
def hermsub(c1, c2): ...
23+
def hermmulx(c): ...
24+
def hermmul(c1, c2): ...
25+
def hermdiv(c1, c2): ...
26+
def hermpow(c, pow, maxpower=...): ...
27+
def hermder(c, m=..., scl=..., axis=...): ...
28+
def hermint(c, m=..., k = ..., lbnd=..., scl=..., axis=...): ...
29+
def hermval(x, c, tensor=...): ...
30+
def hermval2d(x, y, c): ...
31+
def hermgrid2d(x, y, c): ...
32+
def hermval3d(x, y, z, c): ...
33+
def hermgrid3d(x, y, z, c): ...
34+
def hermvander(x, deg): ...
35+
def hermvander2d(x, y, deg): ...
36+
def hermvander3d(x, y, z, deg): ...
37+
def hermfit(x, y, deg, rcond=..., full=..., w=...): ...
38+
def hermcompanion(c): ...
39+
def hermroots(c): ...
40+
def hermgauss(deg): ...
41+
def hermweight(x): ...
42+
43+
class Hermite(ABCPolyBase):
44+
domain: Any
45+
window: Any
46+
basis_name: Any

numpy/polynomial/hermite_e.pyi

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from typing import Any, List
2+
3+
from numpy import ndarray, dtype, int_
4+
from numpy.polynomial._polybase import ABCPolyBase
5+
from numpy.polynomial.polyutils import trimcoef
6+
7+
__all__: list[str]
8+
9+
hermetrim = trimcoef
10+
11+
def poly2herme(pol): ...
12+
def herme2poly(c): ...
13+
14+
hermedomain: ndarray[Any, dtype[int_]]
15+
hermezero: ndarray[Any, dtype[int_]]
16+
hermeone: ndarray[Any, dtype[int_]]
17+
hermex: ndarray[Any, dtype[int_]]
18+
19+
def hermeline(off, scl): ...
20+
def hermefromroots(roots): ...
21+
def hermeadd(c1, c2): ...
22+
def hermesub(c1, c2): ...
23+
def hermemulx(c): ...
24+
def hermemul(c1, c2): ...
25+
def hermediv(c1, c2): ...
26+
def hermepow(c, pow, maxpower=...): ...
27+
def hermeder(c, m=..., scl=..., axis=...): ...
28+
def hermeint(c, m=..., k = ..., lbnd=..., scl=..., axis=...): ...
29+
def hermeval(x, c, tensor=...): ...
30+
def hermeval2d(x, y, c): ...
31+
def hermegrid2d(x, y, c): ...
32+
def hermeval3d(x, y, z, c): ...
33+
def hermegrid3d(x, y, z, c): ...
34+
def hermevander(x, deg): ...
35+
def hermevander2d(x, y, deg): ...
36+
def hermevander3d(x, y, z, deg): ...
37+
def hermefit(x, y, deg, rcond=..., full=..., w=...): ...
38+
def hermecompanion(c): ...
39+
def hermeroots(c): ...
40+
def hermegauss(deg): ...
41+
def hermeweight(x): ...
42+
43+
class HermiteE(ABCPolyBase):
44+
domain: Any
45+
window: Any
46+
basis_name: Any

numpy/polynomial/laguerre.pyi

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from typing import Any, List
2+
3+
from numpy import ndarray, dtype, int_
4+
from numpy.polynomial._polybase import ABCPolyBase
5+
from numpy.polynomial.polyutils import trimcoef
6+
7+
__all__: list[str]
8+
9+
lagtrim = trimcoef
10+
11+
def poly2lag(pol): ...
12+
def lag2poly(c): ...
13+
14+
lagdomain: ndarray[Any, dtype[int_]]
15+
lagzero: ndarray[Any, dtype[int_]]
16+
lagone: ndarray[Any, dtype[int_]]
17+
lagx: ndarray[Any, dtype[int_]]
18+
19+
def lagline(off, scl): ...
20+
def lagfromroots(roots): ...
21+
def lagadd(c1, c2): ...
22+
def lagsub(c1, c2): ...
23+
def lagmulx(c): ...
24+
def lagmul(c1, c2): ...
25+
def lagdiv(c1, c2): ...
26+
def lagpow(c, pow, maxpower=...): ...
27+
def lagder(c, m=..., scl=..., axis=...): ...
28+
def lagint(c, m=..., k = ..., lbnd=..., scl=..., axis=...): ...
29+
def lagval(x, c, tensor=...): ...
30+
def lagval2d(x, y, c): ...
31+
def laggrid2d(x, y, c): ...
32+
def lagval3d(x, y, z, c): ...
33+
def laggrid3d(x, y, z, c): ...
34+
def lagvander(x, deg): ...
35+
def lagvander2d(x, y, deg): ...
36+
def lagvander3d(x, y, z, deg): ...
37+
def lagfit(x, y, deg, rcond=..., full=..., w=...): ...
38+
def lagcompanion(c): ...
39+
def lagroots(c): ...
40+
def laggauss(deg): ...
41+
def lagweight(x): ...
42+
43+
class Laguerre(ABCPolyBase):
44+
domain: Any
45+
window: Any
46+
basis_name: Any

numpy/polynomial/legendre.pyi

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from typing import Any, List
2+
3+
from numpy import ndarray, dtype, int_
4+
from numpy.polynomial._polybase import ABCPolyBase
5+
from numpy.polynomial.polyutils import trimcoef
6+
7+
__all__: list[str]
8+
9+
legtrim = trimcoef
10+
11+
def poly2leg(pol): ...
12+
def leg2poly(c): ...
13+
14+
legdomain: ndarray[Any, dtype[int_]]
15+
legzero: ndarray[Any, dtype[int_]]
16+
legone: ndarray[Any, dtype[int_]]
17+
legx: ndarray[Any, dtype[int_]]
18+
19+
def legline(off, scl): ...
20+
def legfromroots(roots): ...
21+
def legadd(c1, c2): ...
22+
def legsub(c1, c2): ...
23+
def legmulx(c): ...
24+
def legmul(c1, c2): ...
25+
def legdiv(c1, c2): ...
26+
def legpow(c, pow, maxpower=...): ...
27+
def legder(c, m=..., scl=..., axis=...): ...
28+
def legint(c, m=..., k = ..., lbnd=..., scl=..., axis=...): ...
29+
def legval(x, c, tensor=...): ...
30+
def legval2d(x, y, c): ...
31+
def leggrid2d(x, y, c): ...
32+
def legval3d(x, y, z, c): ...
33+
def leggrid3d(x, y, z, c): ...
34+
def legvander(x, deg): ...
35+
def legvander2d(x, y, deg): ...
36+
def legvander3d(x, y, z, deg): ...
37+
def legfit(x, y, deg, rcond=..., full=..., w=...): ...
38+
def legcompanion(c): ...
39+
def legroots(c): ...
40+
def leggauss(deg): ...
41+
def legweight(x): ...
42+
43+
class Legendre(ABCPolyBase):
44+
domain: Any
45+
window: Any
46+
basis_name: Any

numpy/polynomial/polynomial.pyi

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from typing import Any, List
2+
3+
from numpy import ndarray, dtype, int_
4+
from numpy.polynomial._polybase import ABCPolyBase
5+
from numpy.polynomial.polyutils import trimcoef
6+
7+
__all__: list[str]
8+
9+
polytrim = trimcoef
10+
11+
polydomain: ndarray[Any, dtype[int_]]
12+
polyzero: ndarray[Any, dtype[int_]]
13+
polyone: ndarray[Any, dtype[int_]]
14+
polyx: ndarray[Any, dtype[int_]]
15+
16+
def polyline(off, scl): ...
17+
def polyfromroots(roots): ...
18+
def polyadd(c1, c2): ...
19+
def polysub(c1, c2): ...
20+
def polymulx(c): ...
21+
def polymul(c1, c2): ...
22+
def polydiv(c1, c2): ...
23+
def polypow(c, pow, maxpower=...): ...
24+
def polyder(c, m=..., scl=..., axis=...): ...
25+
def polyint(c, m=..., k=..., lbnd=..., scl=..., axis=...): ...
26+
def polyval(x, c, tensor=...): ...
27+
def polyvalfromroots(x, r, tensor=...): ...
28+
def polyval2d(x, y, c): ...
29+
def polygrid2d(x, y, c): ...
30+
def polyval3d(x, y, z, c): ...
31+
def polygrid3d(x, y, z, c): ...
32+
def polyvander(x, deg): ...
33+
def polyvander2d(x, y, deg): ...
34+
def polyvander3d(x, y, z, deg): ...
35+
def polyfit(x, y, deg, rcond=..., full=..., w=...): ...
36+
def polyroots(c): ...
37+
38+
class Polynomial(ABCPolyBase):
39+
domain: Any
40+
window: Any
41+
basis_name: Any

numpy/polynomial/polyutils.pyi

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from typing import List
2+
3+
__all__: List[str]
4+
5+
class RankWarning(UserWarning): ...
6+
class PolyError(Exception): ...
7+
class PolyDomainError(PolyError): ...
8+
9+
# NOTE: Deprecated
10+
# class PolyBase: ...
11+
12+
def trimseq(seq): ...
13+
def as_series(alist, trim=...): ...
14+
def trimcoef(c, tol=...): ...
15+
def getdomain(x): ...
16+
def mapparms(old, new): ...
17+
def mapdomain(x, old, new): ...

0 commit comments

Comments
 (0)