Skip to content

Commit 5a9f664

Browse files
committed
STYLE: Use property decorator syntax in Cython
1 parent 0e16818 commit 5a9f664

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
@@ -219,34 +219,31 @@ cdef class IndexEngine:
219219
def __sizeof__(self):
220220
return self.sizeof()
221221

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

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

230229
cdef inline _do_unique_check(self):
231230

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

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

241-
return self.monotonic_inc == 1
239+
return self.monotonic_inc == 1
242240

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

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

251248
cdef inline _do_monotonic_check(self):
252249
cdef object is_unique
@@ -278,10 +275,9 @@ cdef class IndexEngine:
278275
cdef _check_type(self, object val):
279276
hash(val)
280277

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

286282
cdef inline _ensure_mapping_populated(self):
287283
# 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)