Skip to content

Commit f9e15aa

Browse files
committed
🏷️ fix stubtest errors in numpy.polynomial._polybase
1 parent 1090643 commit f9e15aa

File tree

9 files changed

+47
-23
lines changed

9 files changed

+47
-23
lines changed

src/numpy-stubs/polynomial/_polybase.pyi

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,23 @@ class ABCPolyBase(abc.ABC):
2929
_superscript_mapping: ClassVar[Mapping[int, str]]
3030
_subscript_mapping: ClassVar[Mapping[int, str]]
3131
_use_unicode: ClassVar[bool]
32+
_symbol: str
3233

3334
coef: _InexactObject_1d
34-
domain: Array_1d[np.inexact]
35-
window: Array_1d[np.inexact]
3635

37-
_symbol: str
3836
@property
3937
def symbol(self, /) -> str: ...
38+
39+
#
4040
@property
4141
@abc.abstractmethod
4242
def basis_name(self, /) -> str | None: ...
43+
@property
44+
@abc.abstractmethod
45+
def domain(self, /) -> Array_1d[np.inexact]: ...
46+
@property
47+
@abc.abstractmethod
48+
def window(self, /) -> Array_1d[np.inexact]: ...
4349

4450
#
4551
def __init__(
@@ -82,6 +88,7 @@ class ABCPolyBase(abc.ABC):
8288
def __rmul__(self, x: _AnyOther, /) -> Self: ...
8389
def __rtruediv__(self, x: _AnyOther, /) -> Self: ...
8490
def __rfloordiv__(self, x: _AnyOther, /) -> Self: ...
91+
def __rdiv__(self, x: _AnyOther, /) -> Self: ...
8592
def __rmod__(self, x: _AnyOther, /) -> Self: ...
8693
def __rdivmod__(self, x: _AnyOther, /) -> _Tuple2[Self]: ...
8794
def __len__(self, /) -> int: ...
@@ -98,7 +105,7 @@ class ABCPolyBase(abc.ABC):
98105
#
99106
def copy(self, /) -> Self: ...
100107
def degree(self, /) -> int: ...
101-
def cutdeg(self, /) -> Self: ...
108+
def cutdeg(self, /, deg: int) -> Self: ...
102109
def trim(self, /, tol: _FloatLike_co = 0) -> Self: ...
103110
def truncate(self, /, size: _ToInt) -> Self: ...
104111

@@ -179,12 +186,17 @@ class ABCPolyBase(abc.ABC):
179186
def fromroots(
180187
cls,
181188
roots: _ToNumeric_nd,
182-
domain: CoComplex_1d | None = None,
189+
domain: CoComplex_1d | None = [],
183190
window: CoComplex_1d | None = None,
184191
symbol: str = "x",
185192
) -> Self: ...
186193
@classmethod
187-
def identity(cls, domain: CoComplex_1d | None = None, window: CoComplex_1d | None = None, symbol: str = "x") -> Self: ...
194+
def identity(
195+
cls,
196+
domain: CoComplex_1d | None = None,
197+
window: CoComplex_1d | None = None,
198+
symbol: str = "x",
199+
) -> Self: ...
188200
@classmethod
189201
def basis(
190202
cls,
@@ -194,10 +206,17 @@ class ABCPolyBase(abc.ABC):
194206
symbol: str = "x",
195207
) -> Self: ...
196208
@classmethod
197-
def cast(cls, series: ABCPolyBase, domain: CoComplex_1d | None = None, window: CoComplex_1d | None = None) -> Self: ...
209+
def cast(
210+
cls,
211+
series: ABCPolyBase,
212+
domain: CoComplex_1d | None = None,
213+
window: CoComplex_1d | None = None,
214+
) -> Self: ...
215+
216+
#
198217
@classmethod
199218
def _str_term_unicode(cls, /, i: str, arg_str: str) -> str: ...
200-
@staticmethod
201-
def _str_term_ascii(i: str, arg_str: str) -> str: ...
202-
@staticmethod
203-
def _repr_latex_term(i: str, arg_str: str, needs_parens: bool) -> str: ...
219+
@classmethod
220+
def _str_term_ascii(cls, i: str, arg_str: str) -> str: ...
221+
@classmethod
222+
def _repr_latex_term(cls, i: str, arg_str: str, needs_parens: bool) -> str: ...

src/numpy-stubs/polynomial/chebyshev.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ def chebinterpolate(
134134
) -> Array[_CoNumberT]: ...
135135

136136
class Chebyshev(ABCPolyBase):
137+
domain: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
138+
window: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
137139
basis_name: L["T"] = "T" # pyright: ignore[reportIncompatibleMethodOverride]
138140

139141
@overload

src/numpy-stubs/polynomial/hermite.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,6 @@ hermweight: Final[_FuncWeight[L["hermweight"]]] = ...
100100
def _normed_hermite_n(x: Array[np.float64, _ShapeT], n: int | np.intp) -> Array[np.float64, _ShapeT]: ...
101101

102102
class Hermite(ABCPolyBase):
103+
domain: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
104+
window: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
103105
basis_name: L["H"] = "H" # pyright: ignore[reportIncompatibleMethodOverride]

src/numpy-stubs/polynomial/hermite_e.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,6 @@ hermeweight: Final[_FuncWeight[L["hermeweight"]]] = ...
102102
def _normed_hermite_e_n(x: Array[np.float64, _ShapeT], n: int | np.intp) -> Array[np.float64, _ShapeT]: ...
103103

104104
class HermiteE(ABCPolyBase):
105+
domain: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
106+
window: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
105107
basis_name: L["He"] = "He" # pyright: ignore[reportIncompatibleMethodOverride]

src/numpy-stubs/polynomial/laguerre.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,6 @@ laggauss: Final[_FuncGauss[L["laggauss"]]] = ...
9595
lagweight: Final[_FuncWeight[L["lagweight"]]] = ...
9696

9797
class Laguerre(ABCPolyBase):
98+
domain: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
99+
window: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
98100
basis_name: L["L"] = "L" # pyright: ignore[reportIncompatibleMethodOverride]

src/numpy-stubs/polynomial/legendre.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,6 @@ leggauss: Final[_FuncGauss[L["leggauss"]]] = ...
9595
legweight: Final[_FuncWeight[L["legweight"]]] = ...
9696

9797
class Legendre(ABCPolyBase):
98+
domain: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
99+
window: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
98100
basis_name: L["P"] = "P" # pyright: ignore[reportIncompatibleMethodOverride]

src/numpy-stubs/polynomial/polynomial.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,6 @@ polycompanion: Final[_FuncCompanion[L["polycompanion"]]] = ...
8585
polyroots: Final[_FuncRoots[L["polyroots"]]] = ...
8686

8787
class Polynomial(ABCPolyBase):
88+
domain: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
89+
window: Array_1d[np.float64] = ... # pyright: ignore[reportIncompatibleMethodOverride]
8890
basis_name: None = None # pyright: ignore[reportIncompatibleMethodOverride]

test/static/accept/polynomial_polybase.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from collections.abc import Sequence
22
from decimal import Decimal
33
from fractions import Fraction
44
from typing import Any, Literal as L, TypeAlias
5-
from typing_extensions import LiteralString, TypeVar, assert_type
5+
from typing_extensions import TypeVar, assert_type
66

77
import numpy as np
88
import numpy.polynomial as npp
@@ -82,9 +82,9 @@ assert_type(type(PS_herme).cast(PS_leg), npp.HermiteE)
8282
# attributes / properties
8383

8484
assert_type(PS_all.coef, _Array1D[np.inexact | np.object_])
85-
assert_type(PS_all.domain, _Array1D[np.inexact])
86-
assert_type(PS_all.window, _Array1D[np.inexact])
87-
assert_type(PS_all.symbol, LiteralString)
85+
assert_type(PS_all.domain, _Array1D[np.float64])
86+
assert_type(PS_all.window, _Array1D[np.float64])
87+
assert_type(PS_all.symbol, str)
8888

8989
# instance methods
9090

@@ -104,7 +104,7 @@ assert_type(PS_herme.copy(), npp.HermiteE)
104104
assert_type(PS_lag.copy(), npp.Laguerre)
105105
assert_type(PS_leg.copy(), npp.Legendre)
106106

107-
assert_type(PS_leg.cutdeg(), npp.Legendre)
107+
assert_type(PS_leg.cutdeg(1), npp.Legendre)
108108
assert_type(PS_leg.trim(), npp.Legendre)
109109
assert_type(PS_leg.trim(tol=SC_f_co), npp.Legendre)
110110
assert_type(PS_leg.truncate(SC_i_co), npp.Legendre)

tool/.mypyignore-todo

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ numpy.ma.core.mask_rowcols
5656
numpy.ma.extras.MAxisConcatenator.concatenate
5757
numpy.ma.mrecords.fromtextfile
5858

59-
numpy.polynomial._polybase.ABCPolyBase.__rdiv__
60-
numpy.polynomial._polybase.ABCPolyBase._repr_latex_term
61-
numpy.polynomial._polybase.ABCPolyBase._str_term_ascii
62-
numpy.polynomial._polybase.ABCPolyBase.cutdeg
63-
numpy.polynomial._polybase.ABCPolyBase.domain
64-
numpy.polynomial._polybase.ABCPolyBase.fromroots
65-
numpy.polynomial._polybase.ABCPolyBase.window
6659
numpy.polynomial.chebyshev.cheb2poly
6760
numpy.polynomial.chebyshev.chebadd
6861
numpy.polynomial.chebyshev.chebcompanion

0 commit comments

Comments
 (0)