-
-
Notifications
You must be signed in to change notification settings - Fork 145
feat(series): add and truediv for bools #1314
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
feat(series): add and truediv for bools #1314
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just have to add a few comments so we understand why the ignores are there in the tests.
I caught something when eyeballing the difference between __truediv__()
and truediv()
.
It's odd that truediv()
works for mypy
but __truediv__()
does not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you were able to remove the 2 ignores. Request a review when you've handled my comments from the previous review (2 of which you can now dismiss) and from this review.
Our test coverage used to be poorer than it is now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and __truediv__()
and truediv()
have the same patterns.
Then checked __rtruediv__()
and rtruediv()
and found discrepancies.
Probably should do the same for add()
and radd()
at some point, but that can be another PR
pandas-stubs/core/series.pyi
Outdated
@overload | ||
def __rtruediv__( # pyright: ignore[reportOverlappingOverload] | ||
self: Series[bool], | ||
other: float | Sequence[float] | np_ndarray_anyint | np_ndarray_float, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rtruediv() has
Series[int]and
Series[float]for
other` - please reconcile
pandas-stubs/core/series.pyi
Outdated
@@ -2255,65 +2326,87 @@ class Series(IndexOpsMixin[S1], NDFrame): | |||
self: Series[float], other: _T_COMPLEX | Sequence[_T_COMPLEX] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rtruediv()
has Series[_T_COMPLEX]
for other
- please reconcile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for also checking on __radd__()
/radd()
. I've checked them all now, and found one that I commented on, and one that is missing but I couldn't write a comment. This one is missing from add()
:
@overload
def __add__(self, other: Series[Never]) -> Series: ...
Otherwise, it's all good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @cmp0xff for the nice contribution!
Might want to add some tests for things we don't want to allow, e.g.,
s = pd.Series(["abc", "def"]) # inferred as Series[str]
s / "456"
The latter division will fail, and we are detecting it via the type checks, but having tests for that would be a nice addition, for another PR. Having said that, eagerly awaiting your PRs for subtraction and multiplication!
This is inspired by #1312 (comment) and a follow-up for #1311.
assert_type()
to assert the type of any return value