Skip to content

Commit 71ae658

Browse files
committed
adding test cases for PyObject with many nans
1 parent cf5852b commit 71ae658

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pandas/tests/libs/test_hashtable.py

+23
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,29 @@ def test_unique(self, table_type, dtype):
339339
assert np.all(np.isnan(unique)) and len(unique) == 1
340340

341341

342+
def test_unique_for_nan_objects_floats():
343+
table = ht.PyObjectHashTable()
344+
keys = np.array([float("nan") for i in range(50)], dtype=np.object_)
345+
unique = table.unique(keys)
346+
assert len(unique) == 1
347+
348+
349+
def test_unique_for_nan_objects_complex():
350+
table = ht.PyObjectHashTable()
351+
keys = np.array([complex(float("nan"), 1.0) for i in range(50)], dtype=np.object_)
352+
unique = table.unique(keys)
353+
assert len(unique) == 1
354+
355+
356+
def test_unique_for_nan_objects_tuple():
357+
table = ht.PyObjectHashTable()
358+
keys = np.array(
359+
[1] + [(1.0, (float("nan"), 1.0)) for i in range(50)], dtype=np.object_
360+
)
361+
unique = table.unique(keys)
362+
assert len(unique) == 2
363+
364+
342365
def get_ht_function(fun_name, type_suffix):
343366
return getattr(ht, fun_name)
344367

0 commit comments

Comments
 (0)