Skip to content

Commit 2261af1

Browse files
committed
BUG: Raise TypeError for mismatched signed/unsigned dtypes
1 parent 9b6dafc commit 2261af1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

pandas/core/arrays/interval.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,19 @@ def __new__(
263263
dtype=dtype,
264264
)
265265

266+
# Check for mismatched signed/unsigned integer dtypes after casting
267+
left_dtype = left.dtype
268+
right_dtype = right.dtype
269+
if (
270+
left_dtype.kind in "iu"
271+
and right_dtype.kind in "iu"
272+
and left_dtype.kind != right_dtype.kind
273+
):
274+
raise TypeError(
275+
f"Left and right arrays must have matching signedness. "
276+
f"Got {left_dtype} and {right_dtype}."
277+
)
278+
266279
if verify_integrity:
267280
cls._validate(left, right, dtype=dtype)
268281

@@ -536,19 +549,6 @@ def from_arrays(
536549
left = _maybe_convert_platform_interval(left)
537550
right = _maybe_convert_platform_interval(right)
538551

539-
# Check for mismatched signed/unsigned integer dtypes
540-
left_dtype = left.dtype
541-
right_dtype = right.dtype
542-
if (
543-
left_dtype.kind in "iu"
544-
and right_dtype.kind in "iu"
545-
and left_dtype.kind != right_dtype.kind
546-
):
547-
raise TypeError(
548-
f"Left and right arrays must have matching signedness. "
549-
f"Got {left_dtype} and {right_dtype}."
550-
)
551-
552552
left, right, dtype = cls._ensure_simple_new_inputs(
553553
left,
554554
right,

0 commit comments

Comments
 (0)