codekingpro/portable-devtools
114k
1from abc import ABC, abstractmethod
2from typing import Any, Literal as L, type_check_only
3
4from numpy import ufunc
5
6__all__ = ["NDArrayOperatorsMixin"]
7
8# NOTE: `NDArrayOperatorsMixin` is not formally an abstract baseclass,
9# even though it's reliant on subclasses implementing `__array_ufunc__`
10
11# NOTE: The accepted input- and output-types of the various dunders are
12# completely dependent on how `__array_ufunc__` is implemented.
13# As such, only little type safety can be provided here.
14
15class NDArrayOperatorsMixin(ABC):
16 __slots__ = ()
17
18 @type_check_only
19 @abstractmethod
20 def __array_ufunc__(
21 self,
22 ufunc: ufunc,
23 method: L["__call__", "reduce", "reduceat", "accumulate", "outer", "at"],
24 /,
25 *inputs: Any,
26 **kwargs: Any,
27 ) -> Any: ...
28 def __lt__(self, other: Any) -> Any: ...
29 def __le__(self, other: Any) -> Any: ...
30 def __eq__(self, other: Any) -> Any: ...
31 def __ne__(self, other: Any) -> Any: ...
32 def __gt__(self, other: Any) -> Any: ...
33 def __ge__(self, other: Any) -> Any: ...
34 def __add__(self, other: Any) -> Any: ...
35 def __radd__(self, other: Any) -> Any: ...
36 def __iadd__(self, other: Any) -> Any: ...
37 def __sub__(self, other: Any) -> Any: ...
38 def __rsub__(self, other: Any) -> Any: ...
39 def __isub__(self, other: Any) -> Any: ...
40 def __mul__(self, other: Any) -> Any: ...
41 def __rmul__(self, other: Any) -> Any: ...
42 def __imul__(self, other: Any) -> Any: ...
43 def __matmul__(self, other: Any) -> Any: ...
44 def __rmatmul__(self, other: Any) -> Any: ...
45 def __imatmul__(self, other: Any) -> Any: ...
46 def __truediv__(self, other: Any) -> Any: ...
47 def __rtruediv__(self, other: Any) -> Any: ...
48 def __itruediv__(self, other: Any) -> Any: ...
49 def __floordiv__(self, other: Any) -> Any: ...
50 def __rfloordiv__(self, other: Any) -> Any: ...
51 def __ifloordiv__(self, other: Any) -> Any: ...
52 def __mod__(self, other: Any) -> Any: ...
53 def __rmod__(self, other: Any) -> Any: ...
54 def __imod__(self, other: Any) -> Any: ...
55 def __divmod__(self, other: Any) -> Any: ...
56 def __rdivmod__(self, other: Any) -> Any: ...
57 def __pow__(self, other: Any) -> Any: ...
58 def __rpow__(self, other: Any) -> Any: ...
59 def __ipow__(self, other: Any) -> Any: ...
60 def __lshift__(self, other: Any) -> Any: ...
61 def __rlshift__(self, other: Any) -> Any: ...
62 def __ilshift__(self, other: Any) -> Any: ...
63 def __rshift__(self, other: Any) -> Any: ...
64 def __rrshift__(self, other: Any) -> Any: ...
65 def __irshift__(self, other: Any) -> Any: ...
66 def __and__(self, other: Any) -> Any: ...
67 def __rand__(self, other: Any) -> Any: ...
68 def __iand__(self, other: Any) -> Any: ...
69 def __xor__(self, other: Any) -> Any: ...
70 def __rxor__(self, other: Any) -> Any: ...
71 def __ixor__(self, other: Any) -> Any: ...
72 def __or__(self, other: Any) -> Any: ...
73 def __ror__(self, other: Any) -> Any: ...
74 def __ior__(self, other: Any) -> Any: ...
75 def __neg__(self) -> Any: ...
76 def __pos__(self) -> Any: ...
77 def __abs__(self) -> Any: ...
78 def __invert__(self) -> Any: ...
79 