@@ -56,7 +56,7 @@ from pandas._libs.tslibs.util cimport (
56
56
is_timedelta64_object,
57
57
)
58
58
59
- VALID_CLOSED = frozenset ([' both' , ' neither' , ' left' , ' right' ])
59
+ VALID_INCLUSIVE = frozenset ([' both' , ' neither' , ' left' , ' right' ])
60
60
61
61
62
62
cdef class IntervalMixin:
@@ -85,7 +85,7 @@ cdef class IntervalMixin:
85
85
Returns
86
86
-------
87
87
bool
88
- True if the Interval is closed on the left -side.
88
+ True if the Interval is closed on the right -side.
89
89
"""
90
90
return self .inclusive in (' right' , ' both' )
91
91
@@ -99,7 +99,7 @@ cdef class IntervalMixin:
99
99
Returns
100
100
-------
101
101
bool
102
- True if the Interval is closed on the left-side.
102
+ True if the Interval is not closed on the left-side.
103
103
"""
104
104
return not self .closed_left
105
105
@@ -113,7 +113,7 @@ cdef class IntervalMixin:
113
113
Returns
114
114
-------
115
115
bool
116
- True if the Interval is closed on the left -side.
116
+ True if the Interval is not closed on the right -side.
117
117
"""
118
118
return not self .closed_right
119
119
@@ -188,7 +188,7 @@ cdef class IntervalMixin:
188
188
"""
189
189
return (self .right == self .left) & (self .inclusive != ' both' )
190
190
191
- def _check_closed_matches (self , other , name = ' other' ):
191
+ def _check_inclusive_matches (self , other , name = ' other' ):
192
192
"""
193
193
Check if the inclusive attribute of `other` matches.
194
194
@@ -203,7 +203,7 @@ cdef class IntervalMixin:
203
203
Raises
204
204
------
205
205
ValueError
206
- When `other` is not closed exactly the same as self.
206
+ When `other` is not inclusive exactly the same as self.
207
207
"""
208
208
if self .inclusive != other.inclusive:
209
209
raise ValueError (f" '{name}.inclusive' is {repr(other.inclusive)}, "
@@ -259,14 +259,14 @@ cdef class Interval(IntervalMixin):
259
259
.. deprecated:: 1.5.0
260
260
261
261
inclusive : {'both', 'neither', 'left', 'right'}, default 'both'
262
- Whether the interval is closed on the left-side, right-side, both or
262
+ Whether the interval is inclusive on the left-side, right-side, both or
263
263
neither. See the Notes for more detailed explanation.
264
264
265
265
.. versionadded:: 1.5.0
266
266
267
267
See Also
268
268
--------
269
- IntervalIndex : An Index of Interval objects that are all closed on the
269
+ IntervalIndex : An Index of Interval objects that are all inclusive on the
270
270
same side.
271
271
cut : Convert continuous data into discrete bins (Categorical
272
272
of Interval objects).
@@ -279,13 +279,13 @@ cdef class Interval(IntervalMixin):
279
279
The parameters `left` and `right` must be from the same type, you must be
280
280
able to compare them and they must satisfy ``left <= right``.
281
281
282
- A closed interval (in mathematics denoted by square brackets) contains
283
- its endpoints, i.e. the closed interval ``[0, 5]`` is characterized by the
282
+ A inclusive interval (in mathematics denoted by square brackets) contains
283
+ its endpoints, i.e. the inclusive interval ``[0, 5]`` is characterized by the
284
284
conditions ``0 <= x <= 5``. This is what ``inclusive='both'`` stands for.
285
285
An open interval (in mathematics denoted by parentheses) does not contain
286
286
its endpoints, i.e. the open interval ``(0, 5)`` is characterized by the
287
287
conditions ``0 < x < 5``. This is what ``inclusive='neither'`` stands for.
288
- Intervals can also be half-open or half-closed , i.e. ``[0, 5)`` is
288
+ Intervals can also be half-open or half-inclusive , i.e. ``[0, 5)`` is
289
289
described by ``0 <= x < 5`` (``inclusive='left'``) and ``(0, 5]`` is
290
290
described by ``0 < x <= 5`` (``inclusive='right'``).
291
291
@@ -352,7 +352,7 @@ cdef class Interval(IntervalMixin):
352
352
353
353
cdef readonly str inclusive
354
354
"""
355
- Whether the interval is closed on the left-side, right-side, both or
355
+ Whether the interval is inclusive on the left-side, right-side, both or
356
356
neither.
357
357
"""
358
358
@@ -368,7 +368,7 @@ cdef class Interval(IntervalMixin):
368
368
if inclusive is None :
369
369
inclusive = " right"
370
370
371
- if inclusive not in VALID_CLOSED :
371
+ if inclusive not in VALID_INCLUSIVE :
372
372
raise ValueError (f" invalid option for 'inclusive': {inclusive}" )
373
373
if not left <= right:
374
374
raise ValueError (" left side of interval must be <= right side" )
@@ -522,7 +522,7 @@ cdef class Interval(IntervalMixin):
522
522
"""
523
523
Check whether two Interval objects overlap.
524
524
525
- Two intervals overlap if they share a common point, including closed
525
+ Two intervals overlap if they share a common point, including inclusive
526
526
endpoints. Intervals that only have an open endpoint in common do not
527
527
overlap.
528
528
@@ -551,7 +551,7 @@ cdef class Interval(IntervalMixin):
551
551
>>> i1.overlaps(i3)
552
552
False
553
553
554
- Intervals that share closed endpoints overlap:
554
+ Intervals that share inclusive endpoints overlap:
555
555
556
556
>>> i4 = pd.Interval(0, 1, inclusive='both')
557
557
>>> i5 = pd.Interval(1, 2, inclusive='both')
@@ -568,7 +568,7 @@ cdef class Interval(IntervalMixin):
568
568
raise TypeError (" `other` must be an Interval, "
569
569
f" got {type(other).__name__}" )
570
570
571
- # equality is okay if both endpoints are closed (overlap at a point)
571
+ # equality is okay if both endpoints are inclusive (overlap at a point)
572
572
op1 = le if (self .closed_left and other.closed_right) else lt
573
573
op2 = le if (other.closed_left and self .closed_right) else lt
574
574
@@ -580,16 +580,16 @@ cdef class Interval(IntervalMixin):
580
580
581
581
@ cython.wraparound (False )
582
582
@ cython.boundscheck (False )
583
- def intervals_to_interval_bounds (ndarray intervals , bint validate_closed = True ):
583
+ def intervals_to_interval_bounds (ndarray intervals , bint validate_inclusive = True ):
584
584
"""
585
585
Parameters
586
586
----------
587
587
intervals : ndarray
588
588
Object array of Intervals / nulls.
589
589
590
- validate_closed : bool, default True
591
- Boolean indicating if all intervals must be closed on the same side.
592
- Mismatching closed will raise if True, else return None for closed .
590
+ validate_inclusive : bool, default True
591
+ Boolean indicating if all intervals must be inclusive on the same side.
592
+ Mismatching inclusive will raise if True, else return None for inclusive .
593
593
594
594
Returns
595
595
-------
@@ -602,7 +602,7 @@ def intervals_to_interval_bounds(ndarray intervals, bint validate_closed=True):
602
602
object inclusive = None , interval
603
603
Py_ssize_t i, n = len (intervals)
604
604
ndarray left, right
605
- bint seen_closed = False
605
+ bint seen_inclusive = False
606
606
607
607
left = np.empty(n, dtype = intervals.dtype)
608
608
right = np.empty(n, dtype = intervals.dtype)
@@ -620,13 +620,13 @@ def intervals_to_interval_bounds(ndarray intervals, bint validate_closed=True):
620
620
621
621
left[i] = interval.left
622
622
right[i] = interval.right
623
- if not seen_closed :
624
- seen_closed = True
623
+ if not seen_inclusive :
624
+ seen_inclusive = True
625
625
inclusive = interval.inclusive
626
626
elif inclusive != interval.inclusive:
627
627
inclusive = None
628
- if validate_closed :
629
- raise ValueError (" intervals must all be closed on the same side" )
628
+ if validate_inclusive :
629
+ raise ValueError (" intervals must all be inclusive on the same side" )
630
630
631
631
return left, right, inclusive
632
632
0 commit comments