Skip to content

Commit c089f1f

Browse files
committed
Add inverse to test_datetime64tz_aware
1 parent af7d8f3 commit c089f1f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/test_algos.py

+14
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,20 @@ def test_datetime64tz_aware(self, method, box):
493493
result = method(obj)
494494
assert_series_or_index_or_array_or_categorical_equal(result, expected)
495495

496+
if method == pd.unique:
497+
# [Series/Index].unique do not yet support return_inverse=True
498+
499+
# reuse result as expected outcome of return_inverse case
500+
expected_uniques = result.copy()
501+
result_uniques, result_inverse = method(obj, return_inverse=True)
502+
503+
assert_series_or_index_or_array_or_categorical_equal(
504+
result_uniques, expected_uniques)
505+
506+
# reconstruction can only work if inverse is correct
507+
reconstr = box(result_uniques[result_inverse])
508+
assert_series_or_index_or_array_or_categorical_equal(reconstr, obj)
509+
496510
def test_order_of_appearance(self):
497511
# 9346
498512
# light testing of guarantee of order of appearance

0 commit comments

Comments
 (0)