summaryrefslogtreecommitdiff
path: root/numpy/array_api/_typing.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-08-23 21:32:20 -0600
committerGitHub <noreply@github.com>2021-08-23 21:32:20 -0600
commit098f874144161b6a49efa5108846a408ca8f39b8 (patch)
treed618c32a54705d38e5458669774c88d9f6225212 /numpy/array_api/_typing.py
parenta3ac75c6f92ed158777492f343dc59adeacb745c (diff)
parent7091e4c48ce7af8a5263b6808a6d7976d4af4c6f (diff)
downloadnumpy-098f874144161b6a49efa5108846a408ca8f39b8.tar.gz
Merge pull request #18585 from data-apis/array-api
ENH: Implementation of the NEP 47 (adopting the array API standard)
Diffstat (limited to 'numpy/array_api/_typing.py')
-rw-r--r--numpy/array_api/_typing.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/numpy/array_api/_typing.py b/numpy/array_api/_typing.py
new file mode 100644
index 000000000..d530a91ae
--- /dev/null
+++ b/numpy/array_api/_typing.py
@@ -0,0 +1,44 @@
+"""
+This file defines the types for type annotations.
+
+These names aren't part of the module namespace, but they are used in the
+annotations in the function signatures. The functions in the module are only
+valid for inputs that match the given type annotations.
+"""
+
+__all__ = [
+ "Array",
+ "Device",
+ "Dtype",
+ "SupportsDLPack",
+ "SupportsBufferProtocol",
+ "PyCapsule",
+]
+
+from typing import Any, Sequence, Type, Union
+
+from . import (
+ Array,
+ int8,
+ int16,
+ int32,
+ int64,
+ uint8,
+ uint16,
+ uint32,
+ uint64,
+ float32,
+ float64,
+)
+
+# This should really be recursive, but that isn't supported yet. See the
+# similar comment in numpy/typing/_array_like.py
+NestedSequence = Sequence[Sequence[Any]]
+
+Device = Any
+Dtype = Type[
+ Union[[int8, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64]]
+]
+SupportsDLPack = Any
+SupportsBufferProtocol = Any
+PyCapsule = Any