Skip to content

TST: add CoW test for setitem with Series being set #51296

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 6 commits into from
Feb 11, 2023

Conversation

jorisvandenbossche
Copy link
Member

xref #49473

We already have a test for setitem from #50692, but that only handled setting an array (actually, does that copy the array?), and not setting with a pandas object for which we could use lazy copy mechanism.

This is only adding the test, we seem to actually do an eager copy, so room for optimization.

Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

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

small comment,

the # This is inplace comment is a bit confusing, the docstring says it will never try to write into the underlying array

df.isetitem(1, ser) # This is inplace

ser.loc[0] = 0
expected = df = DataFrame({"a": [7, 8, 9], "b": np.array([4, 5, 6], dtype=dtype)})
Copy link
Member

Choose a reason for hiding this comment

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

I think you want to remove df here?

@phofl
Copy link
Member

phofl commented Feb 10, 2023

@jorisvandenbossche
Copy link
Member Author

The comment in the test was a left-over from copying the previous setitem test, will remove.

But the docstring is actually confusing here, because it is an inplace method in the sense that it is updating the object inplace (we listed this method in the "always inplace" bucket in the draft PDEP). It's only not inplace in the sense that it will not update values inplace.

@phofl
Copy link
Member

phofl commented Feb 10, 2023

Yeah good point, a clarification would probably help

@phofl
Copy link
Member

phofl commented Feb 10, 2023

Fixed a small typo/copy paste issue. otherwise good to merge on greenish

@phofl phofl merged commit 14fc3de into pandas-dev:main Feb 11, 2023
@phofl
Copy link
Member

phofl commented Feb 11, 2023

thx @jorisvandenbossche

failures were unrelated

@jorisvandenbossche jorisvandenbossche deleted the cow-tests-isetitem branch February 11, 2023 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants