Skip to content

Commit

Permalink
fix tests by ignoring the warning for now
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Oct 25, 2023
1 parent b78c0fa commit 75181f7
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,9 @@ def _sliced_from_mgr(self, mgr, axes) -> Series:

def _constructor_sliced_from_mgr(self, mgr, axes):
if self._constructor_sliced is Series:
return self._sliced_from_mgr(mgr, axes)
ser = self._sliced_from_mgr(mgr, axes)
ser._name = None # caller is responsible for setting real name
return ser
assert axes is mgr.axes
return self._constructor_sliced(mgr)

Expand Down
4 changes: 3 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,9 @@ def _constructor(self) -> Callable[..., Series]:
def _constructor_from_mgr(self, mgr, axes):
if self._constructor is Series:
# we are pandas.Series (or a subclass that doesn't override _constructor)
return self._from_mgr(mgr, axes=axes)
ser = self._from_mgr(mgr, axes=axes)
ser._name = None # caller is responsible for setting real name
return ser
else:
assert axes is mgr.axes
return self._constructor(mgr)
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/frame/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,9 @@ def test_frame_sub_nullable_int(any_int_ea_dtype):
tm.assert_frame_equal(result, expected)


@pytest.mark.filterwarnings(
"ignore:Passing a BlockManager|Passing a SingleBlockManager:DeprecationWarning"
)
def test_frame_op_subclass_nonclass_constructor():
# GH#43201 subclass._constructor is a function, not the subclass itself

Expand Down
8 changes: 7 additions & 1 deletion pandas/tests/frame/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
)
import pandas._testing as tm

pytestmark = pytest.mark.filterwarnings(
"ignore:Passing a BlockManager|Passing a SingleBlockManager:DeprecationWarning"
)


@pytest.fixture()
def gpd_style_subclass_df():
Expand Down Expand Up @@ -734,7 +738,9 @@ def test_replace_list_method(self):
# https://github.com/pandas-dev/pandas/pull/46018
df = tm.SubclassedDataFrame({"A": [0, 1, 2]})
msg = "The 'method' keyword in SubclassedDataFrame.replace is deprecated"
with tm.assert_produces_warning(FutureWarning, match=msg):
with tm.assert_produces_warning(
FutureWarning, match=msg, raise_on_extra_warnings=False
):
result = df.replace([1, 2], method="ffill")
expected = tm.SubclassedDataFrame({"A": [0, 0, 0]})
assert isinstance(result, tm.SubclassedDataFrame)
Expand Down
12 changes: 10 additions & 2 deletions pandas/tests/groupby/test_groupby_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import pandas._testing as tm
from pandas.tests.groupby import get_groupby_method_args

pytestmark = pytest.mark.filterwarnings(
"ignore:Passing a BlockManager|Passing a SingleBlockManager:DeprecationWarning"
)


@pytest.mark.parametrize(
"obj",
Expand Down Expand Up @@ -64,7 +68,9 @@ def func(group):
return group.testattr

msg = "DataFrameGroupBy.apply operated on the grouping columns"
with tm.assert_produces_warning(FutureWarning, match=msg):
with tm.assert_produces_warning(
FutureWarning, match=msg, raise_on_extra_warnings=False
):
result = custom_df.groupby("c").apply(func)
expected = tm.SubclassedSeries(["hello"] * 3, index=Index([7, 8, 9], name="c"))
tm.assert_series_equal(result, expected)
Expand Down Expand Up @@ -104,6 +110,8 @@ def test_groupby_resample_preserves_subclass(obj):

# Confirm groupby.resample() preserves dataframe type
msg = "DataFrameGroupBy.resample operated on the grouping columns"
with tm.assert_produces_warning(FutureWarning, match=msg):
with tm.assert_produces_warning(
FutureWarning, match=msg, raise_on_extra_warnings=False
):
result = df.groupby("Buyer").resample("5D").sum()
assert isinstance(result, obj)
3 changes: 3 additions & 0 deletions pandas/tests/reshape/concat/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ def test_duplicate_keys_same_frame():
tm.assert_frame_equal(result, expected)


@pytest.mark.filterwarnings(
"ignore:Passing a BlockManager|Passing a SingleBlockManager:DeprecationWarning"
)
@pytest.mark.parametrize(
"obj",
[
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/reshape/merge/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,9 @@ def test_merge_nan_right2(self):
)[["i1", "i2", "i1_", "i3"]]
tm.assert_frame_equal(result, expected)

@pytest.mark.filterwarnings(
"ignore:Passing a BlockManager|Passing a SingleBlockManager:DeprecationWarning"
)
def test_merge_type(self, df, df2):
class NotADataFrame(DataFrame):
@property
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/reshape/merge/test_merge_ordered.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def test_multigroup(self, left, right):
result = merge_ordered(left, right, on="key", left_by="group")
assert result["group"].notna().all()

@pytest.mark.filterwarnings(
"ignore:Passing a BlockManager|Passing a SingleBlockManager:DeprecationWarning"
)
def test_merge_type(self, left, right):
class NotADataFrame(DataFrame):
@property
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/series/methods/test_to_frame.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from pandas import (
DataFrame,
Index,
Expand Down Expand Up @@ -40,6 +42,9 @@ def test_to_frame(self, datetime_series):
)
tm.assert_frame_equal(rs, xp)

@pytest.mark.filterwarnings(
"ignore:Passing a BlockManager|Passing a SingleBlockManager:DeprecationWarning"
)
def test_to_frame_expanddim(self):
# GH#9762

Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/series/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import pandas as pd
import pandas._testing as tm

pytestmark = pytest.mark.filterwarnings(
"ignore:Passing a BlockManager|Passing a SingleBlockManager:DeprecationWarning"
)


class TestSeriesSubclassing:
@pytest.mark.parametrize(
Expand Down

0 comments on commit 75181f7

Please sign in to comment.