Skip to content

Commit 1bcfd54

Browse files
committed
🏷️ fix stubtest errors in numpy.polynomial.legendre
1 parent 993641d commit 1bcfd54

File tree

2 files changed

+80
-77
lines changed

2 files changed

+80
-77
lines changed
Lines changed: 80 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,46 @@
1-
from typing import Final, Literal as L
1+
from typing import Final, Literal as L, SupportsIndex as CanIndex, overload
22

33
import numpy as np
4-
from _numtype import Array_1d
4+
from _numtype import (
5+
Array,
6+
Array_1d,
7+
CoComplex_1d,
8+
CoFloating_1d,
9+
CoFloating_nd,
10+
CoInteger_1d,
11+
ToComplex128_1d,
12+
ToComplex_1d,
13+
ToComplex_nd,
14+
ToFloat64_1d,
15+
ToObject_1d,
16+
ToObject_nd,
17+
)
518

619
from ._polybase import ABCPolyBase
7-
from ._polytypes import (
8-
_FuncBinOp,
9-
_FuncCompanion,
10-
_FuncDer,
11-
_FuncFit,
12-
_FuncFromRoots,
13-
_FuncGauss,
14-
_FuncInteg,
15-
_FuncLine,
16-
_FuncPoly2Ortho,
17-
_FuncPow,
18-
_FuncRoots,
19-
_FuncUnOp,
20-
_FuncVal,
21-
_FuncVal2D,
22-
_FuncVal3D,
23-
_FuncValFromRoots,
24-
_FuncVander,
25-
_FuncVander2D,
26-
_FuncVander3D,
27-
_FuncWeight,
20+
from .polynomial import (
21+
polyadd as legadd,
22+
polycompanion as legcompanion,
23+
polyder as legder,
24+
polydiv as legdiv,
25+
polyfit as legfit,
26+
polyfromroots as legfromroots,
27+
polygrid2d as leggrid2d,
28+
polygrid3d as leggrid3d,
29+
polyint as legint,
30+
polyline as legline,
31+
polymul as legmul,
32+
polymulx as legmulx,
33+
polypow as legpow,
34+
polyroots as legroots,
35+
polysub as legsub,
36+
polytrim as legtrim,
37+
polyval as legval,
38+
polyval2d as legval2d,
39+
polyval3d as legval3d,
40+
polyvander as legvander,
41+
polyvander2d as legvander2d,
42+
polyvander3d as legvander3d,
2843
)
29-
from .polyutils import trimcoef as legtrim
3044

3145
__all__ = [
3246
"Legendre",
@@ -62,39 +76,55 @@ __all__ = [
6276
"poly2leg",
6377
]
6478

79+
###
80+
6581
legdomain: Final[Array_1d[np.float64]] = ...
6682
legzero: Final[Array_1d[np.int_]] = ...
6783
legone: Final[Array_1d[np.int_]] = ...
6884
legx: Final[Array_1d[np.int_]] = ...
6985

70-
poly2leg: Final[_FuncPoly2Ortho[L["poly2leg"]]] = ...
71-
leg2poly: Final[_FuncUnOp[L["leg2poly"]]] = ...
72-
legline: Final[_FuncLine[L["legline"]]] = ...
73-
legfromroots: Final[_FuncFromRoots[L["legfromroots"]]] = ...
74-
legadd: Final[_FuncBinOp[L["legadd"]]] = ...
75-
legsub: Final[_FuncBinOp[L["legsub"]]] = ...
76-
legmulx: Final[_FuncUnOp[L["legmulx"]]] = ...
77-
legmul: Final[_FuncBinOp[L["legmul"]]] = ...
78-
legdiv: Final[_FuncBinOp[L["legdiv"]]] = ...
79-
legpow: Final[_FuncPow[L["legpow"]]] = ...
80-
legder: Final[_FuncDer[L["legder"]]] = ...
81-
legint: Final[_FuncInteg[L["legint"]]] = ...
82-
legval: Final[_FuncVal[L["legval"]]] = ...
83-
legval2d: Final[_FuncVal2D[L["legval2d"]]] = ...
84-
legval3d: Final[_FuncVal3D[L["legval3d"]]] = ...
85-
legvalfromroots: Final[_FuncValFromRoots[L["legvalfromroots"]]] = ...
86-
leggrid2d: Final[_FuncVal2D[L["leggrid2d"]]] = ...
87-
leggrid3d: Final[_FuncVal3D[L["leggrid3d"]]] = ...
88-
legvander: Final[_FuncVander[L["legvander"]]] = ...
89-
legvander2d: Final[_FuncVander2D[L["legvander2d"]]] = ...
90-
legvander3d: Final[_FuncVander3D[L["legvander3d"]]] = ...
91-
legfit: Final[_FuncFit[L["legfit"]]] = ...
92-
legcompanion: Final[_FuncCompanion[L["legcompanion"]]] = ...
93-
legroots: Final[_FuncRoots[L["legroots"]]] = ...
94-
leggauss: Final[_FuncGauss[L["leggauss"]]] = ...
95-
legweight: Final[_FuncWeight[L["legweight"]]] = ...
86+
###
9687

9788
class Legendre(ABCPolyBase):
9889
domain: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
9990
window: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
10091
basis_name: L["P"] = "P" # pyright: ignore[reportIncompatibleMethodOverride]
92+
93+
###
94+
@overload
95+
def poly2leg(pol: ToFloat64_1d | CoInteger_1d) -> Array_1d[np.float64]: ...
96+
@overload
97+
def poly2leg(pol: CoFloating_1d) -> Array_1d[np.floating]: ...
98+
@overload
99+
def poly2leg(pol: ToComplex128_1d) -> Array_1d[np.complex128]: ...
100+
@overload
101+
def poly2leg(pol: ToComplex_1d) -> Array_1d[np.complexfloating]: ...
102+
@overload
103+
def poly2leg(pol: CoComplex_1d) -> Array_1d[np.inexact]: ...
104+
@overload
105+
def poly2leg(pol: ToObject_1d) -> Array_1d[np.object_]: ...
106+
107+
#
108+
@overload
109+
def leg2poly(c: ToFloat64_1d | CoInteger_1d) -> Array_1d[np.float64]: ...
110+
@overload
111+
def leg2poly(c: CoFloating_1d) -> Array_1d[np.floating]: ...
112+
@overload
113+
def leg2poly(c: ToComplex128_1d) -> Array_1d[np.complex128]: ...
114+
@overload
115+
def leg2poly(c: ToComplex_1d) -> Array_1d[np.complexfloating]: ...
116+
@overload
117+
def leg2poly(c: CoComplex_1d) -> Array_1d[np.inexact]: ...
118+
@overload
119+
def leg2poly(c: ToObject_1d) -> Array_1d[np.object_]: ...
120+
121+
#
122+
@overload
123+
def legweight(x: CoFloating_nd) -> Array[np.float64]: ...
124+
@overload
125+
def legweight(x: ToComplex_nd) -> Array[np.complex128]: ...
126+
@overload
127+
def legweight(x: ToObject_nd) -> Array[np.object_]: ...
128+
129+
#
130+
def leggauss(deg: CanIndex) -> tuple[Array_1d[np.float64], Array_1d[np.float64]]: ...

tool/.mypyignore-todo

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -138,30 +138,3 @@ numpy.polynomial.laguerre.lagvander2d
138138
numpy.polynomial.laguerre.lagvander3d
139139
numpy.polynomial.laguerre.lagweight
140140
numpy.polynomial.laguerre.poly2lag
141-
142-
numpy.polynomial.legendre.leg2poly
143-
numpy.polynomial.legendre.legadd
144-
numpy.polynomial.legendre.legcompanion
145-
numpy.polynomial.legendre.legder
146-
numpy.polynomial.legendre.legdiv
147-
numpy.polynomial.legendre.legfit
148-
numpy.polynomial.legendre.legfromroots
149-
numpy.polynomial.legendre.leggauss
150-
numpy.polynomial.legendre.leggrid2d
151-
numpy.polynomial.legendre.leggrid3d
152-
numpy.polynomial.legendre.legint
153-
numpy.polynomial.legendre.legline
154-
numpy.polynomial.legendre.legmul
155-
numpy.polynomial.legendre.legmulx
156-
numpy.polynomial.legendre.legpow
157-
numpy.polynomial.legendre.legroots
158-
numpy.polynomial.legendre.legsub
159-
numpy.polynomial.legendre.legval
160-
numpy.polynomial.legendre.legval2d
161-
numpy.polynomial.legendre.legval3d
162-
numpy.polynomial.legendre.legvalfromroots
163-
numpy.polynomial.legendre.legvander
164-
numpy.polynomial.legendre.legvander2d
165-
numpy.polynomial.legendre.legvander3d
166-
numpy.polynomial.legendre.legweight
167-
numpy.polynomial.legendre.poly2leg

0 commit comments

Comments
 (0)