Skip to content

Commit 017ed3e

Browse files
use helper for option
1 parent 2961701 commit 017ed3e

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

pandas/core/frame.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -3842,10 +3842,7 @@ def isetitem(self, loc, value) -> None:
38423842
self._iset_item_mgr(loc, arraylike, inplace=False)
38433843

38443844
def __setitem__(self, key, value):
3845-
if (
3846-
get_option("mode.copy_on_write")
3847-
and get_option("mode.data_manager") == "block"
3848-
):
3845+
if using_copy_on_write():
38493846
if sys.getrefcount(self) <= 3:
38503847
raise ChainedAssignmentError("Chained assignment doesn't work!!")
38513848

pandas/core/indexing.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import numpy as np
1515

16-
from pandas._config import get_option
16+
from pandas._config import using_copy_on_write
1717

1818
from pandas._libs.indexing import NDFrameIndexerBase
1919
from pandas._libs.lib import item_from_zerodim
@@ -834,11 +834,8 @@ def _ensure_listlike_indexer(self, key, axis=None, value=None) -> None:
834834

835835
@final
836836
def __setitem__(self, key, value) -> None:
837-
if (
838-
get_option("mode.copy_on_write")
839-
and get_option("mode.data_manager") == "block"
840-
):
841-
print("_LocationIndexer.__setitem__ refcount: ", sys.getrefcount(self.obj))
837+
if using_copy_on_write():
838+
# print("_LocationIndexer.__setitem__ refcount: ",sys.getrefcount(self.obj))
842839
if sys.getrefcount(self.obj) <= 2:
843840
raise ChainedAssignmentError("Chained assignment doesn't work!!")
844841

pandas/core/series.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1074,11 +1074,8 @@ def _get_value(self, label, takeable: bool = False):
10741074
return self.iloc[loc]
10751075

10761076
def __setitem__(self, key, value) -> None:
1077-
if (
1078-
get_option("mode.copy_on_write")
1079-
and get_option("mode.data_manager") == "block"
1080-
):
1081-
print("Series.__getitem__ refcount: ", sys.getrefcount(self))
1077+
if using_copy_on_write():
1078+
# print("Series.__getitem__ refcount: ", sys.getrefcount(self))
10821079
if sys.getrefcount(self) <= 3:
10831080
raise ChainedAssignmentError("Chained assignment doesn't work!!")
10841081

0 commit comments

Comments
 (0)