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 19a47fc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scipy-stubs/special/_ufuncs.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# mypy: disable-error-code="explicit-override, override, misc"
# pyright: reportIncompatibleMethodOverride=false, reportIncompatibleVariableOverride=false, reportImplicitOverride=false
# NOTE: the last 2 ignores are for the `ComplexWarning` stuffs
# mypy: disable-error-code="explicit-override, override, misc, import-not-found, attr-defined"

from types import EllipsisType
from typing import Any, Generic, Literal as L, TypeAlias, TypedDict, final, overload, type_check_only
Expand All @@ -10,6 +11,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 # pyright: ignore[reportAttributeAccessIssue, reportUnknownVariableType, reportUnknownMemberType] # noqa: NPY201

__all__ = [
"agm",
"airy",
Expand Down Expand Up @@ -871,7 +878,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 19a47fc

Please sign in to comment.