Skip to content

Commit

Permalink
🩹 special: workaround for ComplexWarning import on older numpy ve…
Browse files Browse the repository at this point in the history
…rsions
  • Loading branch information
jorenham committed Dec 24, 2024
1 parent 721ba31 commit fefd698
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scipy-stubs/special/_ufuncs.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mypy: disable-error-code="explicit-override, override, misc"
# mypy: disable-error-code="explicit-override, override, misc, import-not-found"
# pyright: reportIncompatibleMethodOverride=false, reportIncompatibleVariableOverride=false, reportImplicitOverride=false

from types import EllipsisType
Expand All @@ -10,6 +10,12 @@ import optype as op
import optype.numpy as onp
from scipy._typing import AnyShape, Casting, EnterNoneMixin, OrderKACF

try:
from numpy.exceptions import ComplexWarning
except ImportError:
# numpy<1.25
ComplexWarning = np.ComplexWarning # type: ignore[attr-defined] # pyright: ignore[reportAttributeAccessIssue, reportUnknownVariableType, reportUnknownMemberType] # noqa: NPY201

__all__ = [
"agm",
"airy",
Expand Down Expand Up @@ -871,7 +877,7 @@ class _UFunc21c1(_WithoutIdentity, _UFunc21[_NameT_co, _IdentityT_co], Generic[_
def __call__(self, a: _ToFloat64_D, b: _ToComplex128_D, /, out: _Out1[_OutT], **kw: Unpack[_Kw21c1]) -> _OutT: ...
#
@override
@deprecated("Casting complex values to real discards the imaginary part.", category=np.exceptions.ComplexWarning)
@deprecated("Casting complex values to real discards the imaginary part.", category=ComplexWarning) # pyright: ignore[reportUnknownArgumentType]
def at(self, a: _CoFloat64ND, indices: _Indices, b: _ToFloat64ND, /) -> None: ...

#
Expand Down

0 comments on commit fefd698

Please sign in to comment.