-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Sparse Ops Cleanup #19782
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
Sparse Ops Cleanup #19782
Conversation
def wrapper(self, other): | ||
is_self_int_dtype = is_integer_dtype(self.dtype) | ||
|
||
fill_int = lambda x: x.fillna(0) | ||
fill_bool = lambda x: x.fillna(False).astype(bool) |
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.
Moving these outside of the function scope to clarify they don't need to be re-defined on each call. _bool_method_SERIES is the topic of a separate PR, but this is sufficiently small to include in assorted-cleanups.
Codecov Report
@@ Coverage Diff @@
## master #19782 +/- ##
==========================================
+ Coverage 91.61% 91.61% +<.01%
==========================================
Files 150 150
Lines 48887 48882 -5
==========================================
- Hits 44786 44782 -4
+ Misses 4101 4100 -1
Continue to review full report at Codecov.
|
@@ -1568,7 +1562,7 @@ def wrapper(self, other): | |||
dtype = getattr(other, 'dtype', None) | |||
other = SparseArray(other, fill_value=self.fill_value, | |||
dtype=dtype) | |||
return _sparse_array_op(self, other, op, name) | |||
return _sparse_array_op(self, other, op, name, series=False) |
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 whole sparse interaction is pretty hacky (I know not addressing this now), but....
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.
Yah, there are a couple of improvements in store for the pass after next (which is just implementing the single-call ops.add_whatever_methods(cls)
)
@@ -1591,4 +1583,5 @@ def wrapper(self, other): | |||
|
|||
sparse_series_special_funcs = dict(arith_method=_arith_method_SPARSE_SERIES, | |||
comp_method=_arith_method_SPARSE_SERIES, | |||
bool_method=None) | |||
bool_method=_bool_method_SERIES) |
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.
can we hold off adding till then
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 is necessary to get rid of the double-call in sparse.series.
thanks |
This is in preparation for implementing the direct-pinning discussed here. The main roadblock to that is SparseSeries which calls ops.add_special_arithmetic_methods twice. This PR gets rid of the double-call, so the follow-up will be straight-forward.
A handful of cleanups are done here too:
SparseArray.__eq__.__name__ == 'eq'