-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
make ops.add_foo take just class #19828
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
Conversation
pandas/core/ops.py
Outdated
------- | ||
arith_method : function | ||
comp_method : function | ||
bool_method : function |
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 think it would be better just have a dict here keyed on the cls and just returns the 5 methods. This seems a bit overkill
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.
Sounds 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.
Implementing this it ends up being pretty close to a wash. We have to key on cls._typ
most of the time but also check for cls._subtyp
for SparseSeries and SparseDataFrame. At this point I'm leaning towards "being a little bit verbose here is OK in this case". The main upside is its helpful to see which wrappers are used where without having to jump around the file.
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.
ok, can do in a single function then
Codecov Report
@@ Coverage Diff @@
## master #19828 +/- ##
=========================================
Coverage ? 91.68%
=========================================
Files ? 150
Lines ? 48943
Branches ? 0
=========================================
Hits ? 44875
Misses ? 4068
Partials ? 0
Continue to review full report at Codecov.
|
pandas/core/ops.py
Outdated
------- | ||
arith_method : function | ||
comp_method : function | ||
bool_method : function |
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.
ok, can do in a single function then
pandas/core/ops.py
Outdated
""" | ||
arith_method, comp_method, bool_method = _get_method_wrappers(cls)[2:] |
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'd rather you now do this an instead use _, _, ...
for the return values its more obvious
|
||
if is_integer_dtype(left) and is_integer_dtype(right): | ||
# series coerces to float64 if result should have NaN/inf | ||
if opname in ('floordiv', 'mod') and (right.values == 0).any(): |
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.
this should go thru the fill_zeros path.
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.
Is this obvious? I don't know the sparse code all that well, have been assuming that the do-it-upfront approach taken here was for a reason.
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.
There will need to be a pass soon to make Series division handle division by zero the way that Index division now does. That might be a reasonable time to take a close look at this.
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.
ok pls add it to the list.
|
||
if is_integer_dtype(left) and is_integer_dtype(right): | ||
# series coerces to float64 if result should have NaN/inf | ||
if opname in ('floordiv', 'mod') and (right.values == 0).any(): |
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.
ok pls add it to the list.
As discussed
Also small cleanup for Sparse ops.