Skip to content

Commit 19ce05e

Browse files
jschendeljreback
authored andcommitted
STYLE: Use property decorator syntax in Cython (#18602)
1 parent 2145e89 commit 19ce05e

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed

pandas/_libs/index.pyx

+18-22
Original file line numberDiff line numberDiff line change
@@ -220,34 +220,31 @@ cdef class IndexEngine:
220220
def __sizeof__(self):
221221
return self.sizeof()
222222

223-
property is_unique:
223+
@property
224+
def is_unique(self):
225+
if self.need_unique_check:
226+
self._do_unique_check()
224227

225-
def __get__(self):
226-
if self.need_unique_check:
227-
self._do_unique_check()
228-
229-
return self.unique == 1
228+
return self.unique == 1
230229

231230
cdef inline _do_unique_check(self):
232231

233232
# this de-facto the same
234233
self._ensure_mapping_populated()
235234

236-
property is_monotonic_increasing:
237-
238-
def __get__(self):
239-
if self.need_monotonic_check:
240-
self._do_monotonic_check()
235+
@property
236+
def is_monotonic_increasing(self):
237+
if self.need_monotonic_check:
238+
self._do_monotonic_check()
241239

242-
return self.monotonic_inc == 1
240+
return self.monotonic_inc == 1
243241

244-
property is_monotonic_decreasing:
242+
@property
243+
def is_monotonic_decreasing(self):
244+
if self.need_monotonic_check:
245+
self._do_monotonic_check()
245246

246-
def __get__(self):
247-
if self.need_monotonic_check:
248-
self._do_monotonic_check()
249-
250-
return self.monotonic_dec == 1
247+
return self.monotonic_dec == 1
251248

252249
cdef inline _do_monotonic_check(self):
253250
cdef object is_unique
@@ -279,10 +276,9 @@ cdef class IndexEngine:
279276
cdef _check_type(self, object val):
280277
hash(val)
281278

282-
property is_mapping_populated:
283-
284-
def __get__(self):
285-
return self.mapping is not None
279+
@property
280+
def is_mapping_populated(self):
281+
return self.mapping is not None
286282

287283
cdef inline _ensure_mapping_populated(self):
288284
# this populates the mapping

pandas/_libs/tslibs/conversion.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ cdef class _TSObject:
203203
# int64_t value # numpy dt64
204204
# object tzinfo
205205

206-
property value:
207-
def __get__(self):
208-
return self.value
206+
@property
207+
def value(self):
208+
return self.value
209209

210210

211211
cpdef int64_t pydt_to_i8(object pydt) except? -1:

0 commit comments

Comments
 (0)