|
85 | 85 | from pandas.compat import PYPY |
86 | 86 | from pandas.compat._constants import ( |
87 | 87 | REF_COUNT, |
88 | | - WARNING_CHECK_DISABLED, |
89 | 88 | ) |
90 | 89 | from pandas.compat._optional import import_optional_dependency |
91 | 90 | from pandas.compat.numpy import function as nv |
@@ -7082,8 +7081,10 @@ def fillna( |
7082 | 7081 | """ |
7083 | 7082 | inplace = validate_bool_kwarg(inplace, "inplace") |
7084 | 7083 | if inplace: |
7085 | | - if not PYPY and not WARNING_CHECK_DISABLED: |
7086 | | - if sys.getrefcount(self) <= REF_COUNT: |
| 7084 | + if not PYPY: |
| 7085 | + if sys.getrefcount( |
| 7086 | + self |
| 7087 | + ) < REF_COUNT and not sys._is_local_in_caller_frame(self): |
7087 | 7088 | warnings.warn( |
7088 | 7089 | _chained_assignment_method_msg, |
7089 | 7090 | ChainedAssignmentError, |
@@ -7329,8 +7330,10 @@ def ffill( |
7329 | 7330 | """ |
7330 | 7331 | inplace = validate_bool_kwarg(inplace, "inplace") |
7331 | 7332 | if inplace: |
7332 | | - if not PYPY and not WARNING_CHECK_DISABLED: |
7333 | | - if sys.getrefcount(self) <= REF_COUNT: |
| 7333 | + if not PYPY: |
| 7334 | + if sys.getrefcount( |
| 7335 | + self |
| 7336 | + ) < REF_COUNT and not sys._is_local_in_caller_frame(self): |
7334 | 7337 | warnings.warn( |
7335 | 7338 | _chained_assignment_method_msg, |
7336 | 7339 | ChainedAssignmentError, |
@@ -7469,8 +7472,10 @@ def bfill( |
7469 | 7472 | """ |
7470 | 7473 | inplace = validate_bool_kwarg(inplace, "inplace") |
7471 | 7474 | if inplace: |
7472 | | - if not PYPY and not WARNING_CHECK_DISABLED: |
7473 | | - if sys.getrefcount(self) <= REF_COUNT: |
| 7475 | + if not PYPY: |
| 7476 | + if sys.getrefcount( |
| 7477 | + self |
| 7478 | + ) < REF_COUNT and not sys._is_local_in_caller_frame(self): |
7474 | 7479 | warnings.warn( |
7475 | 7480 | _chained_assignment_method_msg, |
7476 | 7481 | ChainedAssignmentError, |
@@ -7554,8 +7559,10 @@ def replace( |
7554 | 7559 |
|
7555 | 7560 | inplace = validate_bool_kwarg(inplace, "inplace") |
7556 | 7561 | if inplace: |
7557 | | - if not PYPY and not WARNING_CHECK_DISABLED: |
7558 | | - if sys.getrefcount(self) <= REF_COUNT: |
| 7562 | + if not PYPY: |
| 7563 | + if sys.getrefcount( |
| 7564 | + self |
| 7565 | + ) < REF_COUNT and not sys._is_local_in_caller_frame(self): |
7559 | 7566 | warnings.warn( |
7560 | 7567 | _chained_assignment_method_msg, |
7561 | 7568 | ChainedAssignmentError, |
@@ -7917,8 +7924,10 @@ def interpolate( |
7917 | 7924 | inplace = validate_bool_kwarg(inplace, "inplace") |
7918 | 7925 |
|
7919 | 7926 | if inplace: |
7920 | | - if not PYPY and not WARNING_CHECK_DISABLED: |
7921 | | - if sys.getrefcount(self) <= REF_COUNT: |
| 7927 | + if not PYPY: |
| 7928 | + if sys.getrefcount( |
| 7929 | + self |
| 7930 | + ) < REF_COUNT and not sys._is_local_in_caller_frame(self): |
7922 | 7931 | warnings.warn( |
7923 | 7932 | _chained_assignment_method_msg, |
7924 | 7933 | ChainedAssignmentError, |
@@ -8572,8 +8581,10 @@ def clip( |
8572 | 8581 | inplace = validate_bool_kwarg(inplace, "inplace") |
8573 | 8582 |
|
8574 | 8583 | if inplace: |
8575 | | - if not PYPY and not WARNING_CHECK_DISABLED: |
8576 | | - if sys.getrefcount(self) <= REF_COUNT: |
| 8584 | + if not PYPY: |
| 8585 | + if sys.getrefcount( |
| 8586 | + self |
| 8587 | + ) < REF_COUNT and not sys._is_local_in_caller_frame(self): |
8577 | 8588 | warnings.warn( |
8578 | 8589 | _chained_assignment_method_msg, |
8579 | 8590 | ChainedAssignmentError, |
@@ -10207,8 +10218,10 @@ def where( |
10207 | 10218 | """ |
10208 | 10219 | inplace = validate_bool_kwarg(inplace, "inplace") |
10209 | 10220 | if inplace: |
10210 | | - if not PYPY and not WARNING_CHECK_DISABLED: |
10211 | | - if sys.getrefcount(self) <= REF_COUNT: |
| 10221 | + if not PYPY: |
| 10222 | + if sys.getrefcount( |
| 10223 | + self |
| 10224 | + ) < REF_COUNT and not sys._is_local_in_caller_frame(self): |
10212 | 10225 | warnings.warn( |
10213 | 10226 | _chained_assignment_method_msg, |
10214 | 10227 | ChainedAssignmentError, |
@@ -10271,8 +10284,10 @@ def mask( |
10271 | 10284 | ) -> Self | None: |
10272 | 10285 | inplace = validate_bool_kwarg(inplace, "inplace") |
10273 | 10286 | if inplace: |
10274 | | - if not PYPY and not WARNING_CHECK_DISABLED: |
10275 | | - if sys.getrefcount(self) <= REF_COUNT: |
| 10287 | + if not PYPY: |
| 10288 | + if sys.getrefcount( |
| 10289 | + self |
| 10290 | + ) < REF_COUNT and not sys._is_local_in_caller_frame(self): |
10276 | 10291 | warnings.warn( |
10277 | 10292 | _chained_assignment_method_msg, |
10278 | 10293 | ChainedAssignmentError, |
|
0 commit comments