summaryrefslogtreecommitdiff
path: root/numpy/typing/_scalars.py
diff options
context:
space:
mode:
authorBas van Beek <43369155+BvB93@users.noreply.github.com>2020-10-07 18:53:33 +0200
committerGitHub <noreply@github.com>2020-10-07 19:53:33 +0300
commitfd01786ea4c7dde540cede258ad11d08d25bacfc (patch)
tree6601706476da64b117088d6bbe368bc18521cb53 /numpy/typing/_scalars.py
parent2378c3c987c479cca27470d3d66b5d50e91ad673 (diff)
downloadnumpy-fd01786ea4c7dde540cede258ad11d08d25bacfc.tar.gz
MAINT: Move aliases for common scalar unions to `numpy.typing` (#17429)
* MAINT: Move the `<scalar>Like` unions to `numpy.typing`
Diffstat (limited to 'numpy/typing/_scalars.py')
-rw-r--r--numpy/typing/_scalars.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/numpy/typing/_scalars.py b/numpy/typing/_scalars.py
new file mode 100644
index 000000000..e4fc28b07
--- /dev/null
+++ b/numpy/typing/_scalars.py
@@ -0,0 +1,26 @@
+from typing import Union, Tuple, Any
+
+import numpy as np
+
+# NOTE: `_StrLike` and `_BytesLike` are pointless, as `np.str_` and `np.bytes_`
+# are already subclasses of their builtin counterpart
+
+_CharLike = Union[str, bytes]
+
+_BoolLike = Union[bool, np.bool_]
+_IntLike = Union[int, np.integer]
+_FloatLike = Union[_IntLike, float, np.floating]
+_ComplexLike = Union[_FloatLike, complex, np.complexfloating]
+_NumberLike = Union[int, float, complex, np.number, np.bool_]
+
+_ScalarLike = Union[
+ int,
+ float,
+ complex,
+ str,
+ bytes,
+ np.generic,
+]
+
+# `_VoidLike` is technically not a scalar, but it's close enough
+_VoidLike = Union[Tuple[Any, ...], np.void]