Skip to content

[ArrayManager] TST: run (+fix/skip) pandas/tests/series/indexing tests #40326

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
Mar 12, 2021
Merged
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ jobs:
pytest pandas/tests/groupby/
pytest pandas/tests/resample/
pytest pandas/tests/reshape/merge

pytest pandas/tests/series/methods
pytest pandas/tests/series/test_*
pytest pandas/tests/series/

# indexing subset (temporary since other tests don't pass yet)
pytest pandas/tests/frame/indexing/test_indexing.py::TestDataFrameIndexing::test_setitem_boolean
Expand Down
10 changes: 8 additions & 2 deletions pandas/core/internals/array_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def get_dtypes(self):
def __repr__(self) -> str:
output = type(self).__name__
output += f"\nIndex: {self._axes[0]}"
if self.ndim == 1:
if self.ndim == 2:
output += f"\nColumns: {self._axes[1]}"
output += f"\n{len(self.arrays)} arrays:"
for arr in self.arrays:
Expand Down Expand Up @@ -1143,7 +1143,13 @@ def __init__(
def _verify_integrity(self) -> None:
(n_rows,) = self.shape
assert len(self.arrays) == 1
assert len(self.arrays[0]) == n_rows
arr = self.arrays[0]
assert len(arr) == n_rows
if not arr.ndim == 1:
raise ValueError(
"Passed array should be 1-dimensional, got array with "
f"{arr.ndim} dimensions instead."
)
Copy link
Member

Choose a reason for hiding this comment

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

can you share any of this with the parent classes' _verify_integrity?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really, I think. The parent version assumes the object is 2D, so won't work for SingleArrayManager.
I assume that the part of _verify_integrity that checks the individual array could be factored out into a shared helper function, but I would rather leave that for a follow-up.


@staticmethod
def _normalize_axis(axis):
Expand Down
12 changes: 8 additions & 4 deletions pandas/tests/series/indexing/test_getitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,12 @@ def test_getitem_partial_str_slice_high_reso_with_timedeltaindex(self):
result = ser["1 days, 10:11:12.001001"]
assert result == ser.iloc[1001]

def test_getitem_slice_2d(self, datetime_series):
def test_getitem_slice_2d(self, datetime_series, using_array_manager):
# GH#30588 multi-dimensional indexing deprecated

with tm.assert_produces_warning(FutureWarning):
with tm.assert_produces_warning(
FutureWarning, check_stacklevel=not using_array_manager
):
# GH#30867 Don't want to support this long-term, but
# for now ensure that the warning from Index
# doesn't comes through via Series.__getitem__.
Expand Down Expand Up @@ -518,9 +520,11 @@ def test_getitem_generator(string_series):
Series(date_range("2012-01-01", periods=2, tz="CET")),
],
)
def test_getitem_ndim_deprecated(series):
def test_getitem_ndim_deprecated(series, using_array_manager):
with tm.assert_produces_warning(
FutureWarning, match="Support for multi-dimensional indexing"
FutureWarning,
match="Support for multi-dimensional indexing",
check_stacklevel=not using_array_manager,
):
result = series[:, None]

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/indexing/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ def test_dt64tz_setitem_does_not_mutate_dti(self):
ser = Series(dti)
assert ser._values is not dti
assert ser._values._data.base is not dti._data._data.base
assert ser._mgr.blocks[0].values is not dti
assert ser._mgr.blocks[0].values._data.base is not dti._data._data.base
assert ser._mgr.arrays[0] is not dti
assert ser._mgr.arrays[0]._data.base is not dti._data._data.base

ser[::3] = NaT
assert ser[0] is NaT
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/series/indexing/test_where.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas.core.dtypes.common import is_integer

import pandas as pd
Expand Down Expand Up @@ -471,6 +473,9 @@ def test_where_categorical(klass):
tm.assert_equal(exp, res)


# TODO(ArrayManager) DataFrame.values not yet correctly returning datetime array
# for categorical with datetime categories
@td.skip_array_manager_not_yet_implemented
def test_where_datetimelike_categorical(tz_naive_fixture):
# GH#37682
tz = tz_naive_fixture
Expand Down