@@ -213,8 +213,8 @@ def ndim(self) -> Literal[1]:
213
213
return 1
214
214
215
215
# To make mypy recognize the fields
216
- _left : np . ndarray
217
- _right : np . ndarray
216
+ _left : ArrayLike
217
+ _right : ArrayLike
218
218
_dtype : IntervalDtype
219
219
220
220
# ---------------------------------------------------------------------
@@ -714,7 +714,7 @@ def __getitem__(
714
714
if is_scalar (left ) and isna (left ):
715
715
return self ._fill_value
716
716
return Interval (left , right , self .closed )
717
- if np .ndim (left ) > 1 :
717
+ if np .ndim (left ) > 1 : # type: ignore[arg-type]
718
718
# GH#30588 multi-dimensional indexer disallowed
719
719
raise ValueError ("multi-dimensional indexing not allowed" )
720
720
return self ._shallow_copy (left , right )
@@ -1456,15 +1456,15 @@ def is_non_overlapping_monotonic(self) -> bool:
1456
1456
# at a point when both sides of intervals are included
1457
1457
if self .closed == "both" :
1458
1458
return bool (
1459
- (self ._right [:- 1 ] < self ._left [1 :]).all ()
1460
- or (self ._left [:- 1 ] > self ._right [1 :]).all ()
1459
+ (self ._right [:- 1 ] < self ._left [1 :]).all () # type: ignore[operator]
1460
+ or (self ._left [:- 1 ] > self ._right [1 :]).all () # type: ignore[operator]
1461
1461
)
1462
1462
1463
1463
# non-strict inequality when closed != 'both'; at least one side is
1464
1464
# not included in the intervals, so equality does not imply overlapping
1465
1465
return bool (
1466
- (self ._right [:- 1 ] <= self ._left [1 :]).all ()
1467
- or (self ._left [:- 1 ] >= self ._right [1 :]).all ()
1466
+ (self ._right [:- 1 ] <= self ._left [1 :]).all () # type: ignore[operator]
1467
+ or (self ._left [:- 1 ] >= self ._right [1 :]).all () # type: ignore[operator]
1468
1468
)
1469
1469
1470
1470
# ---------------------------------------------------------------------
@@ -1574,9 +1574,11 @@ def _putmask(self, mask: npt.NDArray[np.bool_], value) -> None:
1574
1574
1575
1575
if isinstance (self ._left , np .ndarray ):
1576
1576
np .putmask (self ._left , mask , value_left )
1577
+ assert isinstance (self ._right , np .ndarray )
1577
1578
np .putmask (self ._right , mask , value_right )
1578
1579
else :
1579
1580
self ._left ._putmask (mask , value_left )
1581
+ assert isinstance (self ._right , ExtensionArray )
1580
1582
self ._right ._putmask (mask , value_right )
1581
1583
1582
1584
def insert (self : IntervalArrayT , loc : int , item : Interval ) -> IntervalArrayT :
@@ -1603,10 +1605,12 @@ def insert(self: IntervalArrayT, loc: int, item: Interval) -> IntervalArrayT:
1603
1605
1604
1606
def delete (self : IntervalArrayT , loc ) -> IntervalArrayT :
1605
1607
if isinstance (self ._left , np .ndarray ):
1606
- new_left = np .delete (self ._left , loc )
1607
- new_right = np .delete (self ._right , loc )
1608
+ new_left : ArrayLike = np .delete (self ._left , loc )
1609
+ assert isinstance (self ._right , np .ndarray )
1610
+ new_right : ArrayLike = np .delete (self ._right , loc )
1608
1611
else :
1609
1612
new_left = self ._left .delete (loc )
1613
+ assert isinstance (self ._right , ExtensionArray )
1610
1614
new_right = self ._right .delete (loc )
1611
1615
return self ._shallow_copy (left = new_left , right = new_right )
1612
1616
@@ -1724,17 +1728,13 @@ def _from_combined(self, combined: np.ndarray) -> IntervalArray:
1724
1728
1725
1729
dtype = self ._left .dtype
1726
1730
if needs_i8_conversion (dtype ):
1727
- # error: "Type[ndarray[Any, Any]]" has no attribute "_from_sequence"
1728
- new_left = type (self ._left )._from_sequence ( # type: ignore[attr-defined]
1729
- nc [:, 0 ], dtype = dtype
1730
- )
1731
- # error: "Type[ndarray[Any, Any]]" has no attribute "_from_sequence"
1732
- new_right = type (self ._right )._from_sequence ( # type: ignore[attr-defined]
1733
- nc [:, 1 ], dtype = dtype
1734
- )
1731
+ assert isinstance (self ._left , ExtensionArray )
1732
+ new_left = type (self ._left )._from_sequence (nc [:, 0 ], dtype = dtype )
1733
+ assert isinstance (self ._right , ExtensionArray )
1734
+ new_right = type (self ._right )._from_sequence (nc [:, 1 ], dtype = dtype )
1735
1735
else :
1736
- new_left = nc [:, 0 ].view (dtype )
1737
- new_right = nc [:, 1 ].view (dtype )
1736
+ new_left = nc [:, 0 ].view (dtype ) # type: ignore[arg-type]
1737
+ new_right = nc [:, 1 ].view (dtype ) # type: ignore[arg-type]
1738
1738
return self ._shallow_copy (left = new_left , right = new_right )
1739
1739
1740
1740
def unique (self ) -> IntervalArray :
0 commit comments