Skip to content

ENH/TST: Add BaseMethodsTests tests for ArrowExtensionArray #47552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 5, 2022
10 changes: 6 additions & 4 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,10 +983,12 @@ def unique(self):

if not isinstance(values, np.ndarray):
result: ArrayLike = values.unique()
if self.dtype.kind in ["m", "M"] and isinstance(self, ABCSeries):
# GH#31182 Series._values returns EA, unpack for backward-compat
if getattr(self.dtype, "tz", None) is None:
result = np.asarray(result)
if (
isinstance(self.dtype, np.dtype) and self.dtype.kind in ["m", "M"]
) and isinstance(self, ABCSeries):
# GH#31182 Series._values returns EA
# unpack numpy datetime for backward-compat
result = np.asarray(result)
else:
result = unique1d(values)

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/extension/base/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from pandas.core.dtypes.common import is_bool_dtype
from pandas.core.dtypes.missing import na_value_for_dtype

import pandas as pd
import pandas._testing as tm
Expand Down Expand Up @@ -49,8 +50,7 @@ def test_value_counts_with_normalize(self, data):
else:
expected = pd.Series(0.0, index=result.index)
expected[result > 0] = 1 / len(values)

if isinstance(data.dtype, pd.core.dtypes.dtypes.BaseMaskedDtype):
if na_value_for_dtype(data.dtype) is pd.NA:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not for this PR, but we probably need to find a way to let authors define na_value_for_dtype

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably similar to #27825

# TODO(GH#44692): avoid special-casing
expected = expected.astype("Float64")

Expand Down
Loading