Skip to content

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

Merged
merged 7 commits into from
Feb 26, 2018
Merged

Conversation

jbrockmendel
Copy link
Member

As discussed

Also small cleanup for Sparse ops.

-------
arith_method : function
comp_method : function
bool_method : function
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good.

Copy link
Member Author

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.

Copy link
Contributor

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

@jreback jreback added Numeric Operations Arithmetic, Comparison, and Logical operations Compat pandas objects compatability with Numpy or Python functions labels Feb 22, 2018
@codecov
Copy link

codecov bot commented Feb 22, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@92dbc78). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #19828   +/-   ##
=========================================
  Coverage          ?   91.68%           
=========================================
  Files             ?      150           
  Lines             ?    48943           
  Branches          ?        0           
=========================================
  Hits              ?    44875           
  Misses            ?     4068           
  Partials          ?        0
Flag Coverage Δ
#multiple 90.06% <100%> (?)
#single 41.86% <81.53%> (?)
Impacted Files Coverage Δ
pandas/core/ops.py 96.94% <100%> (ø)
pandas/core/sparse/frame.py 94.81% <100%> (ø)
pandas/core/sparse/series.py 95.25% <100%> (ø)
pandas/core/sparse/array.py 91.32% <100%> (ø)
pandas/core/series.py 94.41% <100%> (ø)
pandas/core/frame.py 97.23% <100%> (ø)
pandas/core/panel.py 97.3% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92dbc78...45467f1. Read the comment docs.

-------
arith_method : function
comp_method : function
bool_method : function
Copy link
Contributor

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

"""
arith_method, comp_method, bool_method = _get_method_wrappers(cls)[2:]
Copy link
Contributor

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():
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Contributor

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():
Copy link
Contributor

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.

@jreback jreback added this to the 0.23.0 milestone Feb 26, 2018
@jreback jreback merged commit 960a746 into pandas-dev:master Feb 26, 2018
harisbal pushed a commit to harisbal/pandas that referenced this pull request Feb 28, 2018
@jbrockmendel jbrockmendel deleted the spops4 branch June 22, 2018 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants