Skip to content

Commit 59b50c9

Browse files
Update algorithms.py
Allow all defined numpy complex dtypes to work as well as complex128. Note that by default the test suite only tests the complex128 case, but users can add or alter that default by modifying the test suite source code to test other cases. Signed-off-by: Michael Tiemann <[email protected]>
1 parent abfdedb commit 59b50c9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pandas/core/algorithms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ def _ensure_data(values: ArrayLike) -> np.ndarray:
172172
elif is_complex_dtype(values.dtype):
173173
# error: Item "ExtensionDtype" of "Union[Any, ExtensionDtype]"
174174
# has no attribute "itemsize"
175-
if values.dtype.itemsize == 16: # type: ignore[union-attr]
176-
# We have support for complex128
175+
if values.dtype.itemsize in [32, 24, 16, 8]: # type: ignore[union-attr]
176+
# The test suite tests support for complex128; we presume that
177+
# complex64, complex192, and complex256 work as well
177178
return np.asarray(values)
178179
return cast(np.ndarray, values)
179180

0 commit comments

Comments
 (0)