From 6b136cf3c8011b4c740cbb36fa262df4f0b6b719 Mon Sep 17 00:00:00 2001 From: jschendel Date: Sat, 2 Dec 2017 12:02:07 -0700 Subject: [PATCH] STYLE: Use property decorator syntax in Cython --- pandas/_libs/index.pyx | 40 ++++++++++++++---------------- pandas/_libs/tslibs/conversion.pyx | 6 ++--- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/pandas/_libs/index.pyx b/pandas/_libs/index.pyx index fa2e1271f4649..f8371d4855803 100644 --- a/pandas/_libs/index.pyx +++ b/pandas/_libs/index.pyx @@ -220,34 +220,31 @@ cdef class IndexEngine: def __sizeof__(self): return self.sizeof() - property is_unique: + @property + def is_unique(self): + if self.need_unique_check: + self._do_unique_check() - def __get__(self): - if self.need_unique_check: - self._do_unique_check() - - return self.unique == 1 + return self.unique == 1 cdef inline _do_unique_check(self): # this de-facto the same self._ensure_mapping_populated() - property is_monotonic_increasing: - - def __get__(self): - if self.need_monotonic_check: - self._do_monotonic_check() + @property + def is_monotonic_increasing(self): + if self.need_monotonic_check: + self._do_monotonic_check() - return self.monotonic_inc == 1 + return self.monotonic_inc == 1 - property is_monotonic_decreasing: + @property + def is_monotonic_decreasing(self): + if self.need_monotonic_check: + self._do_monotonic_check() - def __get__(self): - if self.need_monotonic_check: - self._do_monotonic_check() - - return self.monotonic_dec == 1 + return self.monotonic_dec == 1 cdef inline _do_monotonic_check(self): cdef object is_unique @@ -279,10 +276,9 @@ cdef class IndexEngine: cdef _check_type(self, object val): hash(val) - property is_mapping_populated: - - def __get__(self): - return self.mapping is not None + @property + def is_mapping_populated(self): + return self.mapping is not None cdef inline _ensure_mapping_populated(self): # this populates the mapping diff --git a/pandas/_libs/tslibs/conversion.pyx b/pandas/_libs/tslibs/conversion.pyx index 7f3cc0a7e81dd..0257d13157acc 100644 --- a/pandas/_libs/tslibs/conversion.pyx +++ b/pandas/_libs/tslibs/conversion.pyx @@ -203,9 +203,9 @@ cdef class _TSObject: # int64_t value # numpy dt64 # object tzinfo - property value: - def __get__(self): - return self.value + @property + def value(self): + return self.value cpdef int64_t pydt_to_i8(object pydt) except? -1: