Skip to content

Commit

Permalink
Add complex dtypes to numpy.array_api result_type
Browse files Browse the repository at this point in the history
  • Loading branch information
asmeurer authored and charris committed Jun 15, 2023
1 parent 3196b22 commit 7760e8e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion numpy/array_api/_dtypes.py
Expand Up @@ -12,6 +12,8 @@
uint64 = np.dtype("uint64")
float32 = np.dtype("float32")
float64 = np.dtype("float64")
complex64 = np.dtype("complex64")
complex128 = np.dtype("complex128")
# Note: This name is changed
bool = np.dtype("bool")

Expand All @@ -26,10 +28,13 @@
uint64,
float32,
float64,
complex64,
complex128,
bool,
)
_boolean_dtypes = (bool,)
_floating_dtypes = (float32, float64)
_real_floating_dtypes = (float32, float64)
_floating_dtypes = (float32, float64, complex64, complex128)
_integer_dtypes = (int8, int16, int32, int64, uint8, uint16, uint32, uint64)
_integer_or_boolean_dtypes = (
bool,
Expand All @@ -45,6 +50,8 @@
_numeric_dtypes = (
float32,
float64,
complex64,
complex128,
int8,
int16,
int32,
Expand All @@ -61,6 +68,7 @@
"integer": _integer_dtypes,
"integer or boolean": _integer_or_boolean_dtypes,
"boolean": _boolean_dtypes,
"real floating-point": _floating_dtypes,
"floating-point": _floating_dtypes,
}

Expand Down Expand Up @@ -133,6 +141,18 @@
(float32, float64): float64,
(float64, float32): float64,
(float64, float64): float64,
(complex64, complex64): complex64,
(complex64, complex128): complex128,
(complex128, complex64): complex128,
(complex128, complex64): complex128,
(float32, complex64): complex64,
(float32, complex128): complex128,
(float64, complex64): complex128,
(float64, complex128): complex128,
(complex64, float32): complex64,
(complex64, float64): complex128,
(complex128, float32): complex128,
(complex128, float64): complex128,
(bool, bool): bool,
}

Expand Down

0 comments on commit 7760e8e

Please sign in to comment.