Skip to content

Commit

Permalink
Fix DatetimeArray-case in test_datetime64tz_aware; create TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Feb 2, 2019
1 parent 78d4758 commit 006d7ad
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions pandas/tests/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ def assert_series_or_index_or_array_or_categorical_equal(left, right):
tm.assert_numpy_array_equal(left, right)
elif isinstance(left, Categorical):
tm.assert_categorical_equal(left, right)
elif isinstance(left, DatetimeArray):
tm.assert_extension_array_equal(left, right)
else:
# will fail
assert isinstance(left, (Series, Index, np.ndarray, Categorical))
assert isinstance(left, (Series, Index, np.ndarray,
Categorical, DatetimeArray))


class TestMatch(object):
Expand Down Expand Up @@ -493,19 +496,19 @@ def test_datetime64tz_aware(self, method, box):
result = method(obj)
assert_series_or_index_or_array_or_categorical_equal(result, expected)

if method == pd.unique:
# [Series/Index].unique do not yet support return_inverse=True

# reuse result as expected outcome of return_inverse case
expected_uniques = result.copy()
result_uniques, result_inverse = method(obj, return_inverse=True)

assert_series_or_index_or_array_or_categorical_equal(
result_uniques, expected_uniques)

# reconstruction can only work if inverse is correct
reconstr = box(result_uniques[result_inverse])
assert_series_or_index_or_array_or_categorical_equal(reconstr, obj)
# TODO: add support for return_inverse to DatetimeArray/DatetimeIndex,
# as well as [[Series/Index].unique

# # reuse result as expected outcome of return_inverse case
# expected_uniques = result.copy()
# result_uniques, result_inverse = method(obj, return_inverse=True)
#
# assert_series_or_index_or_array_or_categorical_equal(
# result_uniques, expected_uniques)
#
# # reconstruction can only work if inverse is correct
# reconstr = box(result_uniques[result_inverse])
# assert_series_or_index_or_array_or_categorical_equal(reconstr, obj)

def test_order_of_appearance(self):
# 9346
Expand Down

0 comments on commit 006d7ad

Please sign in to comment.