From b506bfb54e5e26a1403ef9782e8b4ca9c109209d Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Sun, 26 Nov 2023 01:00:10 +0100 Subject: [PATCH 1/3] Add CoW warning builds --- .github/workflows/unit-tests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 33b6e7a8c2340..4c38324280528 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -73,6 +73,14 @@ jobs: env_file: actions-311.yaml pattern: "not slow and not network and not single_cpu" pandas_copy_on_write: "warn" + - name: "Copy-on-Write 3.10 (warnings)" + env_file: actions-310.yaml + pattern: "not slow and not network and not single_cpu" + pandas_copy_on_write: "warn" + - name: "Copy-on-Write 3.9 (warnings)" + env_file: actions-39.yaml + pattern: "not slow and not network and not single_cpu" + pandas_copy_on_write: "warn" - name: "Pypy" env_file: actions-pypy-39.yaml pattern: "not slow and not network and not single_cpu" From 2834bbb2146a20112b9c34a6089a9748f04ed337 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Sun, 26 Nov 2023 01:04:31 +0100 Subject: [PATCH 2/3] Fix warnings for inplace ops --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index e4e95a973a3c1..7b48e9137fd8d 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -12450,7 +12450,7 @@ def _inplace_method(self, other, op) -> Self: """ warn = True if not PYPY and warn_copy_on_write(): - if sys.getrefcount(self) <= 4: + if sys.getrefcount(self) <= REF_COUNT * 2: # we are probably in an inplace setitem context (e.g. df['a'] += 1) warn = False From f4d1eeee9707ea2feee496690de51738493f76cc Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Sun, 26 Nov 2023 01:05:16 +0100 Subject: [PATCH 3/3] Revert "Fix warnings for inplace ops" This reverts commit 2834bbb2146a20112b9c34a6089a9748f04ed337. --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 7b48e9137fd8d..e4e95a973a3c1 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -12450,7 +12450,7 @@ def _inplace_method(self, other, op) -> Self: """ warn = True if not PYPY and warn_copy_on_write(): - if sys.getrefcount(self) <= REF_COUNT * 2: + if sys.getrefcount(self) <= 4: # we are probably in an inplace setitem context (e.g. df['a'] += 1) warn = False