Skip to content

Make relational operators work with all scalars #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2022

Conversation

Dr-Irv
Copy link
Collaborator

@Dr-Irv Dr-Irv commented Aug 1, 2022

Made it so any scalar is comparable to a Series.

@Dr-Irv Dr-Irv requested a review from twoertwein August 1, 2022 00:16
Copy link
Member

@twoertwein twoertwein left a comment

Choose a reason for hiding this comment

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

Happy to merge!

There are places where the annotations for the operators is relatively strict in regard to the type of Series ,e.g., to prevent __ge__(self: Series[int], other: Series[str]). Could replace Scalar with S1 but I assume that might be too strict/create too many false negatives?

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented Aug 1, 2022

There are places where the annotations for the operators is relatively strict in regard to the type of Series ,e.g., to prevent __ge__(self: Series[int], other: Series[str]). Could replace Scalar with S1 but I assume that might be too strict/create too many false negatives?

I like the idea of using S1 here. If the Series has a known type, we are then saying you can only compare to that type. Most of the time, the Series is really Series[Any] so allowing any comparison to S1 will work fine.

This will then prevent doing Series[Timestamp] comparing to Timedelta, which is something we want to pick up.

Let's put it out there and see if we get any reports. Tests are passing with using S1.

@twoertwein twoertwein merged commit d7307e5 into pandas-dev:main Aug 1, 2022
@twoertwein
Copy link
Member

Thanks @Dr-Irv !

@Dr-Irv Dr-Irv deleted the relopstimedelta branch December 28, 2022 15:18
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.

Unsupported operand types for > ("Series[Any]" and "Timedelta")
2 participants