Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,3 @@ repos:
types: [python]
files: ^pandas/tests
language: python
exclude: |
(?x)
^pandas/tests/generic/test_generic.py # GH50380
4 changes: 3 additions & 1 deletion pandas/_testing/asserters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,9 @@ def assert_indexing_slices_equivalent(ser: Series, l_slc: slice, i_slc: slice) -
assert_series_equal(ser[l_slc], expected)


def assert_metadata_equivalent(left, right) -> None:
def assert_metadata_equivalent(
left: DataFrame | Series, right: DataFrame | Series | None = None
) -> None:
"""
Check that ._metadata attributes are equivalent.
"""
Expand Down
16 changes: 8 additions & 8 deletions pandas/tests/generic/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def construct(box, shape, value=None, dtype=None, **kwargs):
return box(arr, dtype=dtype, **kwargs)


class Generic:
class TestGeneric:
@pytest.mark.parametrize(
"func",
[
Expand All @@ -66,7 +66,7 @@ def test_rename(self, frame_or_series, func):

for axis in frame_or_series._AXIS_ORDERS:
kwargs = {axis: idx}
obj = construct(4, **kwargs)
obj = construct(frame_or_series, 4, **kwargs)

# rename a single axis
result = obj.rename(**{axis: func})
Expand All @@ -83,21 +83,21 @@ def test_get_numeric_data(self, frame_or_series):
}

# get the numeric data
o = construct(n, **kwargs)
o = construct(frame_or_series, n, **kwargs)
result = o._get_numeric_data()
tm.assert_equal(result, o)

# non-inclusion
result = o._get_bool_data()
expected = construct(n, value="empty", **kwargs)
expected = construct(frame_or_series, n, value="empty", **kwargs)
if isinstance(o, DataFrame):
# preserve columns dtype
expected.columns = o.columns[:0]
tm.assert_equal(result, expected)
tm.assert_equal(result.reset_index(drop=True), expected)
Copy link
Member

Choose a reason for hiding this comment

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

@topper-123 is this right?

In [1]: ser = Series([1,2,3])

In [2]: ser.index
Out[2]: RangeIndex(start=0, stop=3, step=1)

In [3]: ser._get_bool_data()
Out[3]: Series([], dtype: int64)

In [4]: ser._get_bool_data().index
Out[4]: Index([], dtype='object')

Copy link
Member

Choose a reason for hiding this comment

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

@phershbe OK for now could you please just add a comment with

# https://github.com/pandas-dev/pandas/issues/50862

above this line? then we can get this in and address that separately if needed


# get the bool data
arr = np.array([True, True, False, True])
o = construct(n, value=arr, **kwargs)
o = construct(frame_or_series, n, value=arr, **kwargs)
result = o._get_numeric_data()
tm.assert_equal(result, o)

Expand Down Expand Up @@ -160,7 +160,7 @@ def f(dtype):

msg = (
"compound dtypes are not implemented "
f"in the {frame_or_series.__name__} frame_or_series"
f"in the {frame_or_series.__name__} constructor"
)

with pytest.raises(NotImplementedError, match=msg):
Expand Down Expand Up @@ -257,7 +257,7 @@ def test_api_compat(self, func, frame_or_series):
# GH 12021
# compat for __name__, __qualname__

obj = (frame_or_series, 5)
obj = construct(frame_or_series, 5)
f = getattr(obj, func)
assert f.__name__ == func
assert f.__qualname__.endswith(func)
Expand Down