Skip to content

TST: Get tests to run and fix them to pass #50636

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 5 commits into from
Jan 21, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 9 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,22 @@ 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)
# https://github.com/pandas-dev/pandas/issues/50862
tm.assert_equal(result.reset_index(drop=True), expected)

# 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 +161,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 +258,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