@@ -7,7 +7,7 @@ import array as _array
7
7
import datetime as dt
8
8
import enum
9
9
from abc import abstractmethod
10
- from types import EllipsisType , TracebackType , MappingProxyType , GenericAlias
10
+ from types import EllipsisType , ModuleType , TracebackType , MappingProxyType , GenericAlias
11
11
from decimal import Decimal
12
12
from fractions import Fraction
13
13
from uuid import UUID
@@ -210,7 +210,7 @@ from typing import (
210
210
# This is because the `typeshed` stubs for the standard library include
211
211
# `typing_extensions` stubs:
212
212
# https://github.com/python/typeshed/blob/main/stdlib/typing_extensions.pyi
213
- from typing_extensions import Generic , LiteralString , Protocol , Self , TypeVar , overload
213
+ from typing_extensions import CapsuleType , Generic , LiteralString , Protocol , Self , TypeVar, overload
214
214
215
215
from numpy import (
216
216
core ,
@@ -763,7 +763,7 @@ class _SupportsWrite(Protocol[_AnyStr_contra]):
763
763
def write (self , s : _AnyStr_contra , / ) -> object : ...
764
764
765
765
__version__ : LiteralString
766
- __array_api_version__ : LiteralString
766
+ __array_api_version__ : Final = "2023.12"
767
767
test : PytestTester
768
768
769
769
@@ -1431,7 +1431,7 @@ class _ArrayOrScalarCommon:
1431
1431
def __array_priority__ (self ) -> float : ...
1432
1432
@property
1433
1433
def __array_struct__ (self ) -> Any : ... # builtins.PyCapsule
1434
- def __array_namespace__ (self , * , api_version : None | _ArrayAPIVersion = ... ) -> Any : ...
1434
+ def __array_namespace__ (self , / , * , api_version : _ArrayAPIVersion | None = None ) -> ModuleType : ...
1435
1435
def __setstate__ (self , state : tuple [
1436
1436
SupportsIndex , # version
1437
1437
_ShapeLike , # Shape
@@ -1798,11 +1798,6 @@ _ArrayTD64_co: TypeAlias = NDArray[np.bool | integer[Any] | timedelta64]
1798
1798
# Introduce an alias for `dtype` to avoid naming conflicts.
1799
1799
_dtype : TypeAlias = dtype [_ScalarType ]
1800
1800
1801
- if sys .version_info >= (3 , 13 ):
1802
- from types import CapsuleType as _PyCapsule
1803
- else :
1804
- _PyCapsule : TypeAlias = Any
1805
-
1806
1801
_ArrayAPIVersion : TypeAlias = L ["2021.12" , "2022.12" , "2023.12" ]
1807
1802
1808
1803
@type_check_only
@@ -3063,14 +3058,14 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
3063
3058
3064
3059
def __dlpack__ (
3065
3060
self : NDArray [number [Any ]],
3061
+ / ,
3066
3062
* ,
3067
- stream : int | Any | None = ...,
3068
- max_version : tuple [int , int ] | None = ...,
3069
- dl_device : tuple [int , L [0 ]] | None = ...,
3070
- copy : bool | None = ...,
3071
- ) -> _PyCapsule : ...
3072
-
3073
- def __dlpack_device__ (self ) -> tuple [int , L [0 ]]: ...
3063
+ stream : int | Any | None = None ,
3064
+ max_version : tuple [int , int ] | None = None ,
3065
+ dl_device : tuple [int , int ] | None = None ,
3066
+ copy : builtins .bool | None = None ,
3067
+ ) -> CapsuleType : ...
3068
+ def __dlpack_device__ (self , / ) -> tuple [L [1 ], L [0 ]]: ...
3074
3069
3075
3070
def bitwise_count (
3076
3071
self ,
@@ -4727,12 +4722,12 @@ class matrix(ndarray[_Shape2DType_co, _DType_co]):
4727
4722
4728
4723
@type_check_only
4729
4724
class _SupportsDLPack (Protocol [_T_contra ]):
4730
- def __dlpack__ (self , * , stream : None | _T_contra = ... ) -> _PyCapsule : ...
4725
+ def __dlpack__ (self , / , * , stream : _T_contra | None = None ) -> CapsuleType : ...
4731
4726
4732
4727
def from_dlpack (
4733
- obj : _SupportsDLPack [None ],
4728
+ x : _SupportsDLPack [None ],
4734
4729
/ ,
4735
4730
* ,
4736
- device : L ["cpu" ] | None = ... ,
4737
- copy : bool | None = ... ,
4738
- ) -> NDArray [Any ]: ...
4731
+ device : L ["cpu" ] | None = None ,
4732
+ copy : builtins . bool | None = None ,
4733
+ ) -> NDArray [number [ Any ] | np . bool ]: ...
0 commit comments