Skip to content

Commit 7e023ea

Browse files
committed
adding test cases for unique
1 parent e1e22ae commit 7e023ea

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/test_algos.py

+17
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,23 @@ def test_obj_none_preservation(self):
501501

502502
tm.assert_numpy_array_equal(result, expected, strict_nan=True)
503503

504+
def test_signed_zero(self):
505+
a = np.array([-0.0, 0.0])
506+
result = pd.unique(a)
507+
expected = np.array([-0.0]) # 0.0 and -0.0 are equivalent
508+
tm.assert_numpy_array_equal(result, expected)
509+
510+
def test_different_nans(self):
511+
# create different nans from bit-patterns:
512+
NAN1 = struct.unpack("d", struct.pack("=Q", 0x7ff8000000000000))[0]
513+
NAN2 = struct.unpack("d", struct.pack("=Q", 0x7ff8000000000001))[0]
514+
assert NAN1 != NAN1
515+
assert NAN2 != NAN2
516+
a = np.array([NAN1, NAN2]) # NAN1 and NAN2 are equivalent
517+
result = pd.unique(a)
518+
expected = np.array([np.nan])
519+
tm.assert_numpy_array_equal(result, expected)
520+
504521

505522
class TestIsin(object):
506523

0 commit comments

Comments
 (0)