@@ -4,7 +4,9 @@ from types import NotImplementedType
4
4
from typing import Any , ClassVar , Final , Generic , Literal , Protocol , TypeAlias , TypedDict , final , overload , type_check_only
5
5
from typing_extensions import ParamSpec , TypeVar , Unpack
6
6
7
- from scipy ._typing import AnyBool , EnterNoneMixin
7
+ import optype .numpy as onp
8
+
9
+ from scipy ._typing import ExitMixin
8
10
9
11
__all__ = [
10
12
"BackendNotImplementedError" ,
@@ -71,12 +73,14 @@ ArgumentReplacerType: TypeAlias = Callable[
71
73
class _BackendState : ...
72
74
73
75
@final
74
- class _SetBackendContext (EnterNoneMixin ):
76
+ class _SetBackendContext (ExitMixin ):
75
77
def __init__ (self , / , * args : object , ** kwargs : object ) -> None : ...
78
+ def __enter__ (self , / ) -> None : ...
76
79
77
80
@final
78
- class _SkipBackendContext (EnterNoneMixin ):
81
+ class _SkipBackendContext (ExitMixin ):
79
82
def __init__ (self , / , * args : object , ** kwargs : object ) -> None : ...
83
+ def __enter__ (self , / ) -> None : ...
80
84
81
85
@final
82
86
class _Function (Generic [_Tss , _T_co ]):
@@ -96,7 +100,7 @@ class Dispatchable(Generic[_T_co]):
96
100
type : _DispatchType [_T_co ]
97
101
coercible : Final [bool ]
98
102
99
- def __init__ (self , / , value : _T_co , dispatch_type : _DispatchType [_T_co ], coercible : AnyBool = True ) -> None : ...
103
+ def __init__ (self , / , value : _T_co , dispatch_type : _DispatchType [_T_co ], coercible : onp . ToBool = True ) -> None : ...
100
104
@overload
101
105
def __getitem__ (self , index : Literal [1 , - 1 ], / ) -> _T_co : ...
102
106
@overload
@@ -124,15 +128,15 @@ def generate_multimethod(
124
128
) -> _Function [_Tss , _T ]: ...
125
129
126
130
#
127
- def set_backend (backend : _Backend , coerce : AnyBool = False , only : AnyBool = False ) -> _SetBackendContext : ...
131
+ def set_backend (backend : _Backend , coerce : onp . ToBool = False , only : onp . ToBool = False ) -> _SetBackendContext : ...
128
132
def skip_backend (backend : _Backend ) -> _SkipBackendContext : ...
129
133
130
134
#
131
135
def set_global_backend (
132
- backend : _Backend , coerce : AnyBool = False , only : AnyBool = False , * , try_last : AnyBool = False
136
+ backend : _Backend , coerce : onp . ToBool = False , only : onp . ToBool = False , * , try_last : onp . ToBool = False
133
137
) -> None : ...
134
138
def register_backend (backend : _Backend ) -> None : ...
135
- def clear_backends (domain : str | None , registered : AnyBool = True , globals : AnyBool = False ) -> None : ...
139
+ def clear_backends (domain : str | None , registered : onp . ToBool = True , globals : onp . ToBool = False ) -> None : ...
136
140
137
141
#
138
142
def mark_as (dispatch_type : type [_T ] | str ) -> Callable [[_T ], Dispatchable [_T ]]: ...
@@ -144,37 +148,37 @@ def all_of_type(
144
148
@overload
145
149
def wrap_single_convertor (
146
150
convert_single : Callable [[_V , _DispatchType [_V ], bool ], _C ],
147
- ) -> Callable [[Iterable [Dispatchable [_V ]], AnyBool ], list [_C ]]: ...
151
+ ) -> Callable [[Iterable [Dispatchable [_V ]], onp . ToBool ], list [_C ]]: ...
148
152
@overload
149
153
def wrap_single_convertor (
150
154
convert_single : Callable [[_V , _DispatchType [_V ], bool ], NotImplementedType ],
151
- ) -> Callable [[Iterable [Dispatchable [_V ]], AnyBool ], NotImplementedType ]: ...
155
+ ) -> Callable [[Iterable [Dispatchable [_V ]], onp . ToBool ], NotImplementedType ]: ...
152
156
@overload
153
157
def wrap_single_convertor (
154
158
convert_single : Callable [[_V , _DispatchType [_V ], bool ], _C | NotImplementedType ],
155
- ) -> Callable [[Iterable [Dispatchable [_V ]], AnyBool ], list [_C ] | NotImplementedType ]: ...
159
+ ) -> Callable [[Iterable [Dispatchable [_V ]], onp . ToBool ], list [_C ] | NotImplementedType ]: ...
156
160
@overload
157
161
def wrap_single_convertor_instance (
158
162
convert_single : Callable [[_S , _V , _DispatchType [_V ], bool ], _C ],
159
- ) -> Callable [[_S , Iterable [Dispatchable [_V ]], AnyBool ], list [_C ]]: ...
163
+ ) -> Callable [[_S , Iterable [Dispatchable [_V ]], onp . ToBool ], list [_C ]]: ...
160
164
@overload
161
165
def wrap_single_convertor_instance (
162
166
convert_single : Callable [[_S , _V , _DispatchType [_V ], bool ], NotImplementedType ],
163
- ) -> Callable [[_S , Iterable [Dispatchable [_V ]], AnyBool ], NotImplementedType ]: ...
167
+ ) -> Callable [[_S , Iterable [Dispatchable [_V ]], onp . ToBool ], NotImplementedType ]: ...
164
168
@overload
165
169
def wrap_single_convertor_instance (
166
170
convert_single : Callable [[_S , _V , _DispatchType [_V ], bool ], _C | NotImplementedType ],
167
- ) -> Callable [[_S , Iterable [Dispatchable [_V ]], AnyBool ], list [_C ] | NotImplementedType ]: ...
171
+ ) -> Callable [[_S , Iterable [Dispatchable [_V ]], onp . ToBool ], list [_C ] | NotImplementedType ]: ...
168
172
169
173
#
170
174
def determine_backend (
171
- value : _V , dispatch_type : _DispatchType [_V ], * , domain : str , only : AnyBool = True , coerce : AnyBool = False
175
+ value : _V , dispatch_type : _DispatchType [_V ], * , domain : str , only : onp . ToBool = True , coerce : onp . ToBool = False
172
176
) -> _SetBackendContext : ...
173
177
def determine_backend_multi (
174
178
dispatchables : Iterable [_V | Dispatchable [_V ]],
175
179
* ,
176
180
domain : str ,
177
- only : AnyBool = True ,
178
- coerce : AnyBool = False ,
181
+ only : onp . ToBool = True ,
182
+ coerce : onp . ToBool = False ,
179
183
** kwargs : Unpack [_DetermineBackendMultiKwargs [_T ]],
180
184
) -> _SetBackendContext : ...
0 commit comments