Skip to content

CoW: Warn for cases that go through putmask #56168

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 10 commits into from
Dec 4, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Nov 25, 2023

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Open for suggestions how we can improve the put mask mechanism to avoid duplicate warnings

xref #56019

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

With #55522, we will also have to pass down whether we already warned about chained assignment

Comment on lines 55 to 57
class _AlreadyWarned:
def __init__(self):
self.warned_already = False
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a small comment here about why such a class is needed (in contrast to a simple boolean argument)?

Copy link
Member Author

Choose a reason for hiding this comment

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

added

df.clip(lower=2, inplace=True)
if warn_copy_on_write:
with tm.assert_cow_warning():
df.clip(lower=2, inplace=True)
Copy link
Member

Choose a reason for hiding this comment

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

Should this ideally give a more specific warning about an inplace method?
Because right now this gives the general setting on a view warning

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure we can change the message

Co-authored-by: Joris Van den Bossche <[email protected]>
@phofl
Copy link
Member Author

phofl commented Dec 4, 2023

Yeah message sounds good, we can always iterate again if needed

@jorisvandenbossche
Copy link
Member

With #55522, we will also have to pass down whether we already warned about chained assignment

I added a small commit to do this, the other comments we can address in follow-ups

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.

3 participants