Skip to content

Conversation

Aniketsy
Copy link
Contributor

This PR adds a check in IntervalIndex.from_arrays to raise a TypeError when integer arrays have mismatched signedness. Includes a unit test to verify the behavior.

Please let me know if my approach or fix needs any improvements . I’m open to feedback and happy to make changes based on suggestions.
Thankyou !

@Aniketsy
Copy link
Contributor Author

@jbrockmendel please review these changes when you get a chance.

copy: bool = False,
dtype: Dtype | None = None,
) -> IntervalIndex:
# Check for mismatched signed/unsigned integer dtypes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it would make more sense to do this on the IntervalArray.from_arrays method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I will update changes in IntervalArray.from_arrays

@Aniketsy
Copy link
Contributor Author

Aniketsy commented Oct 3, 2025

@jbrockmendel I’ve updated this as per your suggestions.

) -> Self:
# Check for mismatched signed/unsigned integer dtypes
left_dtype = getattr(left, "dtype", None)
right_dtype = getattr(right, "dtype", None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think putting this after the _maybe_convert_platform_interval calls would be more robust. e.g. if one is a list and the other is uint64?

Also is it just int vs uint we care about, or also e.g. int32 vs int64?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are checking int vs unit .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason not to move this to after the _maybe_convert_platform_interval calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, i have updated, also added whatsnew note, please let me know if this needs improvement.


# Check for mismatched signed/unsigned integer dtypes
left_dtype = getattr(left, "dtype", None)
right_dtype = getattr(right, "dtype", None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the getattr should be unnecessary. the attribute should always be there now that this is moved to after

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, got it. i have updated the code and removed none check for dtype.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: IntervalIndex.from_arrays with int64 vs uint64 arrays
2 participants