Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
phofl committed Feb 9, 2023
commit 58bffc9487ad54adf5a1b33ffa044e0984c8f0b8
5 changes: 3 additions & 2 deletions pandas/tests/copy_view/test_interp_fillna.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_interpolate_no_op(using_copy_on_write, method):
tm.assert_frame_equal(df, df_orig)


@pytest.mark.parametrize("func", ["pad", "ffill", "backfill", "bfill"])
@pytest.mark.parametrize("func", ["ffill", "bfill"])
def test_interp_fill_functions(using_copy_on_write, func):
# Check that these takes the same code paths as interpolate
df = DataFrame({"a": [1, 2]})
Expand Down Expand Up @@ -144,7 +144,8 @@ def test_interpolate_downcast(using_copy_on_write):
arr_a = get_array(df, "a")
df.interpolate(method="pad", inplace=True, downcast="infer")

assert df._mgr._has_no_reference(0)
if using_copy_on_write:
assert df._mgr._has_no_reference(0)
assert np.shares_memory(arr_a, get_array(df, "a"))


Expand Down
10 changes: 7 additions & 3 deletions pandas/tests/frame/methods/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_interpolate_inplace(self, frame_or_series, using_array_manager, request
assert np.shares_memory(orig, obj.values)
assert orig.squeeze()[1] == 1.5

def test_interp_basic(self):
def test_interp_basic(self, using_copy_on_write):
df = DataFrame(
{
"A": [1, 2, np.nan, 4],
Expand All @@ -75,8 +75,12 @@ def test_interp_basic(self):
# check we didn't operate inplace GH#45791
cvalues = df["C"]._values
dvalues = df["D"].values
assert not np.shares_memory(cvalues, result["C"]._values)
assert not np.shares_memory(dvalues, result["D"]._values)
if using_copy_on_write:
assert np.shares_memory(cvalues, result["C"]._values)
assert np.shares_memory(dvalues, result["D"]._values)
else:
assert not np.shares_memory(cvalues, result["C"]._values)
assert not np.shares_memory(dvalues, result["D"]._values)

res = df.interpolate(inplace=True)
assert res is None
Expand Down