Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.9/dist-packages/numpy/array_api/_typing.py: 0%
18 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-03 06:39 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-03 06:39 +0000
1"""
2This file defines the types for type annotations.
4These names aren't part of the module namespace, but they are used in the
5annotations in the function signatures. The functions in the module are only
6valid for inputs that match the given type annotations.
7"""
9from __future__ import annotations
11__all__ = [
12 "Array",
13 "Device",
14 "Dtype",
15 "SupportsDLPack",
16 "SupportsBufferProtocol",
17 "PyCapsule",
18]
20import sys
22from typing import (
23 Any,
24 Literal,
25 Sequence,
26 Type,
27 Union,
28 TypeVar,
29 Protocol,
30)
32from ._array_object import Array
33from numpy import (
34 dtype,
35 int8,
36 int16,
37 int32,
38 int64,
39 uint8,
40 uint16,
41 uint32,
42 uint64,
43 float32,
44 float64,
45)
47_T_co = TypeVar("_T_co", covariant=True)
49class NestedSequence(Protocol[_T_co]):
50 def __getitem__(self, key: int, /) -> _T_co | NestedSequence[_T_co]: ...
51 def __len__(self, /) -> int: ...
53Device = Literal["cpu"]
55Dtype = dtype[Union[
56 int8,
57 int16,
58 int32,
59 int64,
60 uint8,
61 uint16,
62 uint32,
63 uint64,
64 float32,
65 float64,
66]]
68if sys.version_info >= (3, 12):
69 from collections.abc import Buffer as SupportsBufferProtocol
70else:
71 SupportsBufferProtocol = Any
73PyCapsule = Any
75class SupportsDLPack(Protocol):
76 def __dlpack__(self, /, *, stream: None = ...) -> PyCapsule: ...