110
110
)
111
111
112
112
113
- IntervalSideT = Union [TimeArrayLike , np .ndarray ]
113
+ IntervalSide = Union [TimeArrayLike , np .ndarray ]
114
114
IntervalOrNA = Union [Interval , float ]
115
115
116
116
_interval_shared_docs : dict [str , str ] = {}
@@ -219,8 +219,8 @@ def ndim(self) -> Literal[1]:
219
219
return 1
220
220
221
221
# To make mypy recognize the fields
222
- _left : IntervalSideT
223
- _right : IntervalSideT
222
+ _left : IntervalSide
223
+ _right : IntervalSide
224
224
_dtype : IntervalDtype
225
225
226
226
# ---------------------------------------------------------------------
@@ -237,8 +237,8 @@ def __new__(
237
237
data = extract_array (data , extract_numpy = True )
238
238
239
239
if isinstance (data , cls ):
240
- left : IntervalSideT = data ._left
241
- right : IntervalSideT = data ._right
240
+ left : IntervalSide = data ._left
241
+ right : IntervalSide = data ._right
242
242
closed = closed or data .closed
243
243
dtype = IntervalDtype (left .dtype , closed = closed )
244
244
else :
@@ -280,8 +280,8 @@ def __new__(
280
280
@classmethod
281
281
def _simple_new (
282
282
cls ,
283
- left : IntervalSideT ,
284
- right : IntervalSideT ,
283
+ left : IntervalSide ,
284
+ right : IntervalSide ,
285
285
dtype : IntervalDtype ,
286
286
) -> Self :
287
287
result = IntervalMixin .__new__ (cls )
@@ -299,7 +299,7 @@ def _ensure_simple_new_inputs(
299
299
closed : IntervalClosedType | None = None ,
300
300
copy : bool = False ,
301
301
dtype : Dtype | None = None ,
302
- ) -> tuple [IntervalSideT , IntervalSideT , IntervalDtype ]:
302
+ ) -> tuple [IntervalSide , IntervalSide , IntervalDtype ]:
303
303
"""Ensure correctness of input parameters for cls._simple_new."""
304
304
from pandas .core .indexes .base import ensure_index
305
305
@@ -1031,8 +1031,8 @@ def _concat_same_type(cls, to_concat: Sequence[IntervalArray]) -> Self:
1031
1031
raise ValueError ("Intervals must all be closed on the same side." )
1032
1032
closed = closed_set .pop ()
1033
1033
1034
- left = np .concatenate ([interval .left for interval in to_concat ])
1035
- right = np .concatenate ([interval .right for interval in to_concat ])
1034
+ left : IntervalSide = np .concatenate ([interval .left for interval in to_concat ])
1035
+ right : IntervalSide = np .concatenate ([interval .right for interval in to_concat ])
1036
1036
1037
1037
left , right , dtype = cls ._ensure_simple_new_inputs (left , right , closed = closed )
1038
1038
@@ -1283,7 +1283,7 @@ def _format_space(self) -> str:
1283
1283
# Vectorized Interval Properties/Attributes
1284
1284
1285
1285
@property
1286
- def left (self ):
1286
+ def left (self ) -> Index :
1287
1287
"""
1288
1288
Return the left endpoints of each Interval in the IntervalArray as an Index.
1289
1289
@@ -1303,7 +1303,7 @@ def left(self):
1303
1303
return Index (self ._left , copy = False )
1304
1304
1305
1305
@property
1306
- def right (self ):
1306
+ def right (self ) -> Index :
1307
1307
"""
1308
1308
Return the right endpoints of each Interval in the IntervalArray as an Index.
1309
1309
@@ -1855,11 +1855,17 @@ def isin(self, values) -> npt.NDArray[np.bool_]:
1855
1855
return isin (self .astype (object ), values .astype (object ))
1856
1856
1857
1857
@property
1858
- def _combined (self ) -> IntervalSideT :
1859
- left = self .left ._values .reshape (- 1 , 1 )
1860
- right = self .right ._values .reshape (- 1 , 1 )
1858
+ def _combined (self ) -> IntervalSide :
1859
+ # error: Item "ExtensionArray" of "ExtensionArray | ndarray[Any, Any]"
1860
+ # has no attribute "reshape" [union-attr]
1861
+ left = self .left ._values .reshape (- 1 , 1 ) # type: ignore[union-attr]
1862
+ right = self .right ._values .reshape (- 1 , 1 ) # type: ignore[union-attr]
1861
1863
if needs_i8_conversion (left .dtype ):
1862
- comb = left ._concat_same_type ([left , right ], axis = 1 )
1864
+ # error: Item "ndarray[Any, Any]" of "Any | ndarray[Any, Any]" has
1865
+ # no attribute "_concat_same_type"
1866
+ comb = left ._concat_same_type ( # type: ignore[union-attr]
1867
+ [left , right ], axis = 1
1868
+ )
1863
1869
else :
1864
1870
comb = np .concatenate ([left , right ], axis = 1 )
1865
1871
return comb
0 commit comments