Skip to content

Commit 2ae0094

Browse files
remove allow_setting from cache_readonly
1 parent fd2beb9 commit 2ae0094

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

pandas/_libs/properties.pyx

+2-25
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,12 @@ from cpython cimport (
99
cdef class CachedProperty(object):
1010

1111
cdef readonly:
12-
object func, name, __doc__, allow_setting
12+
object func, name, __doc__
1313

14-
def __init__(self, func=None, allow_setting=False):
15-
if func is not None:
16-
self.func = func
17-
self.name = func.__name__
18-
self.__doc__ = getattr(func, '__doc__', None)
19-
self.allow_setting = allow_setting
20-
21-
def __call__(self, func, doc=None):
14+
def __init__(self, func):
2215
self.func = func
2316
self.name = func.__name__
2417
self.__doc__ = getattr(func, '__doc__', None)
25-
return self
2618

2719
def __get__(self, obj, typ):
2820
# Get the cache or set a default one if needed
@@ -42,21 +34,6 @@ cdef class CachedProperty(object):
4234
PyDict_SetItem(cache, self.name, val)
4335
return val
4436

45-
def __set__(self, obj, value):
46-
47-
if not self.allow_setting:
48-
raise Exception("cannot set values for [%s]" % self.name)
49-
50-
# Get the cache or set a default one if needed
51-
cache = getattr(obj, '_cache', None)
52-
if cache is None:
53-
try:
54-
cache = obj._cache = {}
55-
except (AttributeError):
56-
return
57-
58-
PyDict_SetItem(cache, self.name, value)
59-
6037

6138
cache_readonly = CachedProperty
6239

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ def _is_strictly_monotonic_decreasing(self):
14011401
def is_lexsorted_for_tuple(self, tup):
14021402
return True
14031403

1404-
@cache_readonly(allow_setting=True)
1404+
@cache_readonly
14051405
def is_unique(self):
14061406
""" return if the index has unique values """
14071407
return self._engine.is_unique

0 commit comments

Comments
 (0)