Skip to content

Commit 1d11a90

Browse files
committed
Add np complex64 and np.nan tests
1 parent 9e558ce commit 1d11a90

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

pandas/_libs/algos.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import numpy as np
1515

1616
cimport numpy as cnp
1717
from numpy cimport (
18+
NPY_COMPLEX64,
1819
NPY_COMPLEX128,
1920
NPY_FLOAT32,
2021
NPY_FLOAT64,

pandas/_libs/algos_common_helper.pxi.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dtypes = [('float64', 'FLOAT64', 'float64'),
4747
('uint16', 'UINT16', 'uint16'),
4848
('uint32', 'UINT32', 'uint32'),
4949
('uint64', 'UINT64', 'uint64'),
50+
('complex64', 'COMPLEX64', 'complex64'),
5051
('complex128', 'COMPLEX128', 'complex128')
5152
# ('platform_int', 'INT', 'int_'),
5253
# ('object', 'OBJECT', 'object_'),

pandas/core/dtypes/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def ensure_float(arr):
9797
ensure_int32 = algos.ensure_int32
9898
ensure_int16 = algos.ensure_int16
9999
ensure_int8 = algos.ensure_int8
100+
ensure_complex64 = algos.ensure_complex64
100101
ensure_complex128 = algos.ensure_complex128
101102
ensure_platform_int = algos.ensure_platform_int
102103
ensure_object = algos.ensure_object

pandas/tests/indexes/multi/test_duplicates.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from pandas import (
99
DatetimeIndex,
10-
MultiIndex,
10+
MultiIndex, Series,
1111
)
1212
import pandas._testing as tm
1313

@@ -299,6 +299,27 @@ def test_duplicated_drop_duplicates():
299299
tm.assert_index_equal(idx.drop_duplicates(keep=False), expected)
300300

301301

302+
@pytest.mark.parametrize(
303+
"array,expected,dtype",
304+
[
305+
(
306+
[np.nan + np.nan * 1j, 0, 1j, 1j, 1, 1 + 1j, 1 + 2j, 1 + 1j, np.nan, np.nan + np.nan * 1j],
307+
Series([False, False, False, True, False, False, False, True, False, True], dtype=bool),
308+
np.complex64
309+
),
310+
311+
(
312+
[np.nan + np.nan * 1j, 0, 1j, 1j, 1, 1 + 1j, 1 + 2j, 1 + 1j, np.nan, np.nan + np.nan * 1j],
313+
Series([False, False, False, True, False, False, False, True, False, True], dtype=bool),
314+
np.complex128
315+
)
316+
],
317+
)
318+
def test_duplicated_series_complex_numbers(array, expected, dtype):
319+
result = Series(array, dtype=dtype).duplicated()
320+
tm.assert_series_equal(result, expected)
321+
322+
302323
def test_multi_drop_duplicates_pos_args_deprecation():
303324
# GH#41485
304325
idx = MultiIndex.from_arrays([[1, 2, 3, 1], [1, 2, 3, 1]])

0 commit comments

Comments
 (0)