Skip to content

Commit b777745

Browse files
committed
Add complex dtypes to numpy.array_api result_type
Original NumPy Commit: 33064b882c53811e1952f1b29d748d644db783e6
1 parent fa82dc0 commit b777745

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

array_api_strict/_dtypes.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
uint64 = np.dtype("uint64")
1313
float32 = np.dtype("float32")
1414
float64 = np.dtype("float64")
15+
complex64 = np.dtype("complex64")
16+
complex128 = np.dtype("complex128")
1517
# Note: This name is changed
1618
bool = np.dtype("bool")
1719

@@ -26,10 +28,13 @@
2628
uint64,
2729
float32,
2830
float64,
31+
complex64,
32+
complex128,
2933
bool,
3034
)
3135
_boolean_dtypes = (bool,)
32-
_floating_dtypes = (float32, float64)
36+
_real_floating_dtypes = (float32, float64)
37+
_floating_dtypes = (float32, float64, complex64, complex128)
3338
_integer_dtypes = (int8, int16, int32, int64, uint8, uint16, uint32, uint64)
3439
_integer_or_boolean_dtypes = (
3540
bool,
@@ -45,6 +50,8 @@
4550
_numeric_dtypes = (
4651
float32,
4752
float64,
53+
complex64,
54+
complex128,
4855
int8,
4956
int16,
5057
int32,
@@ -61,6 +68,7 @@
6168
"integer": _integer_dtypes,
6269
"integer or boolean": _integer_or_boolean_dtypes,
6370
"boolean": _boolean_dtypes,
71+
"real floating-point": _floating_dtypes,
6472
"floating-point": _floating_dtypes,
6573
}
6674

@@ -133,6 +141,18 @@
133141
(float32, float64): float64,
134142
(float64, float32): float64,
135143
(float64, float64): float64,
144+
(complex64, complex64): complex64,
145+
(complex64, complex128): complex128,
146+
(complex128, complex64): complex128,
147+
(complex128, complex64): complex128,
148+
(float32, complex64): complex64,
149+
(float32, complex128): complex128,
150+
(float64, complex64): complex128,
151+
(float64, complex128): complex128,
152+
(complex64, float32): complex64,
153+
(complex64, float64): complex128,
154+
(complex128, float32): complex128,
155+
(complex128, float64): complex128,
136156
(bool, bool): bool,
137157
}
138158

0 commit comments

Comments
 (0)