Skip to content

Commit 439efbe

Browse files
committed
BUG: Raise TypeError for mismatched signed/unsigned dtypes
1 parent 736ae02 commit 439efbe

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

pandas/core/arrays/interval.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,20 @@ def from_arrays(
533533
copy: bool = False,
534534
dtype: Dtype | None = None,
535535
) -> Self:
536+
# Check for mismatched signed/unsigned integer dtypes
537+
left_dtype = getattr(left, "dtype", None)
538+
right_dtype = getattr(right, "dtype", None)
539+
if (
540+
left_dtype is not None
541+
and right_dtype is not None
542+
and left_dtype.kind in "iu"
543+
and right_dtype.kind in "iu"
544+
and left_dtype.kind != right_dtype.kind
545+
):
546+
raise TypeError(
547+
f"Left and right arrays must have matching signedness. "
548+
f"Got {left_dtype} and {right_dtype}."
549+
)
536550
left = _maybe_convert_platform_interval(left)
537551
right = _maybe_convert_platform_interval(right)
538552

pandas/core/indexes/interval.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -310,20 +310,6 @@ def from_arrays(
310310
copy: bool = False,
311311
dtype: Dtype | None = None,
312312
) -> IntervalIndex:
313-
# Check for mismatched signed/unsigned integer dtypes
314-
left_dtype = getattr(left, "dtype", None)
315-
right_dtype = getattr(right, "dtype", None)
316-
if (
317-
left_dtype is not None
318-
and right_dtype is not None
319-
and left_dtype.kind in "iu"
320-
and right_dtype.kind in "iu"
321-
and left_dtype.kind != right_dtype.kind
322-
):
323-
raise TypeError(
324-
f"Left and right arrays must have matching signedness. "
325-
f"Got {left_dtype} and {right_dtype}."
326-
)
327313
with rewrite_exception("IntervalArray", cls.__name__):
328314
array = IntervalArray.from_arrays(
329315
left, right, closed, copy=copy, dtype=dtype

0 commit comments

Comments
 (0)