File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ Template for intervaltree
44WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
55"""
66
7+ from pandas._libs.algos import is_monotonic
8+
79ctypedef fused scalar_t:
810 float64_t
911 float32_t
@@ -101,6 +103,17 @@ cdef class IntervalTree(IntervalMixin):
101103
102104 return self._is_overlapping
103105
106+ @property
107+ def is_monotonic_increasing(self):
108+ """
109+ Return True if the IntervalTree is monotonic increasing (only equal or
110+ increasing values), else False
111+ """
112+ values = [self.right, self.left]
113+
114+ sort_order = np.lexsort(values)
115+ return is_monotonic(sort_order, False)[0]
116+
104117 def get_loc(self, scalar_t key):
105118 """Return all positions corresponding to intervals that overlap with
106119 the given scalar key
Original file line number Diff line number Diff line change 77from pandas ._config import get_option
88
99from pandas ._libs import Timedelta , Timestamp
10- from pandas ._libs .algos import is_monotonic
1110from pandas ._libs .interval import Interval , IntervalMixin , IntervalTree
1211from pandas .compat import add_metaclass
1312from pandas .util ._decorators import Appender , cache_readonly
@@ -450,10 +449,7 @@ def is_monotonic_increasing(self):
450449 Return True if the IntervalIndex is monotonic increasing (only equal or
451450 increasing values), else False
452451 """
453- values = [self .right , self .left ]
454-
455- sort_order = np .lexsort (values )
456- return is_monotonic (sort_order , False )[0 ]
452+ return self ._engine .is_monotonic_increasing
457453
458454 @cache_readonly
459455 def is_monotonic_decreasing (self ):
You can’t perform that action at this time.
0 commit comments