Skip to content

Commit 60c9a73

Browse files
committed
🥅 np.poly* workarounds for Any shape overload bugs
1 parent 7d95d01 commit 60c9a73

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

‎src/numpy-stubs/@test/static/accept/lib_polynomial.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ assert_type(
8989
assert_type(np.polyfit(AR_u4, AR_c16, 1.0, cov=True), tuple[_nt.Array[np.complex128], _nt.Array[np.complex128]])
9090

9191
assert_type(np.polyval(AR_b, AR_b), _nt.Array[np.bool])
92-
assert_type(np.polyval(AR_u4, AR_b), _nt.Array[np.unsignedinteger])
93-
assert_type(np.polyval(AR_i8, AR_i8), _nt.Array[np.signedinteger])
94-
assert_type(np.polyval(AR_f8, AR_i8), _nt.Array[np.floating])
95-
assert_type(np.polyval(AR_i8, AR_c16), _nt.Array[np.complexfloating])
92+
assert_type(np.polyval(AR_u4, AR_b), _nt.Array[np.uint32])
93+
assert_type(np.polyval(AR_i8, AR_i8), _nt.Array[np.int64])
94+
assert_type(np.polyval(AR_f8, AR_i8), _nt.Array[np.float64])
95+
assert_type(np.polyval(AR_i8, AR_c16), _nt.Array[np.complex128])
9696
assert_type(np.polyval(AR_O, AR_O), _nt.Array[np.object_])
9797

9898
assert_type(np.polyadd(poly_obj, AR_i8), np.poly1d) # type: ignore[assert-type] # mypy fail

‎src/numpy-stubs/lib/_polynomial_impl.pyi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,18 @@ def polyfit(
410410
) -> _Tuple_didd[_nt.Array[np.complex128]]: ...
411411

412412
#
413+
@overload # workaround for microsoft/pyright#10232
414+
def polyval(p: _nt.Casts[_ScalarT, _nt.NeitherShape], x: _nt._ToArray_nnd[_ScalarT]) -> _nt.Array[_ScalarT]: ...
415+
@overload # workaround for microsoft/pyright#10232
416+
def polyval(
417+
p: _nt.CastsWith[_ScalarT, _NumberT, _nt.NeitherShape], x: _nt._ToArray_nnd[_ScalarT]
418+
) -> _nt.Array[_NumberT]: ...
419+
@overload # workaround for microsoft/pyright#10232
420+
def polyval(p: _nt._ToArray_nnd[_ScalarT], x: _nt.Casts[_ScalarT, _nt.NeitherShape]) -> _nt.Array[_ScalarT]: ...
421+
@overload # workaround for microsoft/pyright#10232
422+
def polyval(
423+
p: _nt._ToArray_nnd[_ScalarT], x: _nt.CastsWith[_ScalarT, _NumberT, _nt.NeitherShape]
424+
) -> _nt.Array[_NumberT]: ...
413425
@overload
414426
def polyval(p: _nt.ToBool_1d, x: _nt.ToBool_0d) -> np.bool: ...
415427
@overload

0 commit comments

Comments
 (0)