Skip to content
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

Fix Series v Index bool ops #22173

Merged
merged 11 commits into from
Sep 23, 2018
Merged

Conversation

jbrockmendel
Copy link
Member

Series boolean ops tests need some serious cleanup and fleshing out. This gets separates out one fix before going in to clean up the tests.

@codecov
Copy link

codecov bot commented Aug 2, 2018

Codecov Report

Merging #22173 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #22173      +/-   ##
==========================================
+ Coverage   92.17%   92.18%   +<.01%     
==========================================
  Files         169      169              
  Lines       50778    50783       +5     
==========================================
+ Hits        46807    46814       +7     
+ Misses       3971     3969       -2
Flag Coverage Δ
#multiple 90.59% <100%> (ø) ⬆️
#single 42.33% <65.21%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/ops.py 97.37% <100%> (+0.29%) ⬆️

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 1c113db...44aa551. Read the comment docs.

@gfyoung gfyoung added Bug Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff labels Aug 3, 2018
x = ensure_object(x)
y = ensure_object(y)
result = libops.vec_binop(x, y, op)
assert not isinstance(y, (list, ABCSeries, ABCIndexClass))
Copy link
Member

@gfyoung gfyoung Aug 3, 2018

Choose a reason for hiding this comment

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

From an error reporting perspective, I might go for:

if isinstance(y, (list, ABCSeries, ABCIndexClass)):
   raise

A bare assert statement would unfortunately not provide much info to the end-user (admittedly, my proposed change assumes that the TypeError raised has some kind of message). At the very least, adding an error message on the assert would be useful.

Copy link
Member

Choose a reason for hiding this comment

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

This comment BTW applies to any of your other assert statements.

@@ -1433,6 +1433,20 @@ def test_ops_datetimelike_align(self):
result = (dt2.to_frame() - dt.to_frame())[0]
assert_series_equal(result, expected)

def test_bool_ops_with_index(self):
# GH#19792
# TODO: reversed ops still raises, GH#22092
Copy link
Member

Choose a reason for hiding this comment

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

Can we have an xfail test for that in this PR?

(unless you plan to patch the reversed op in the near term, then not needed)

Copy link
Member Author

Choose a reason for hiding this comment

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

+1 on this idea. I'll wait til AM to implement it, ideally on the follow-up to #22153.

Copy link
Contributor

Choose a reason for hiding this comment

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

can you add this test?

@jreback
Copy link
Contributor

jreback commented Sep 4, 2018

let me have another look, can you rebase

@jbrockmendel
Copy link
Member Author

Rebased+green

ovalues = other
finalizer = lambda x: x.__finalize__(self)

filler = (fill_int if is_self_int_dtype and is_other_int_dtype
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment on what is going on with the filler

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

small comments, pls rebase

@@ -1433,6 +1433,20 @@ def test_ops_datetimelike_align(self):
result = (dt2.to_frame() - dt.to_frame())[0]
assert_series_equal(result, expected)

def test_bool_ops_with_index(self):
# GH#19792
# TODO: reversed ops still raises, GH#22092
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add this test?

@pep8speaks
Copy link

Hello @jbrockmendel! Thanks for updating the PR.

@jreback
Copy link
Contributor

jreback commented Sep 18, 2018

doesn't this overlap with #22293 ?

@jbrockmendel
Copy link
Member Author

Yep, commented to that effect over there.

@jreback
Copy link
Contributor

jreback commented Sep 18, 2018

ok then, merge that one first?

@jbrockmendel
Copy link
Member Author

ok then, merge that one first?

Sure. After rebase this'll be a small follow-up

@jreback jreback added this to the 0.24.0 milestone Sep 23, 2018
@@ -627,6 +604,42 @@ def test_ops_datetimelike_align(self):
result = (dt2.to_frame() - dt.to_frame())[0]
assert_series_equal(result, expected)

@pytest.mark.parametrize('op', [
operator.and_,
Copy link
Contributor

Choose a reason for hiding this comment

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

pls add these as a fixture in conftest (follow-on PR)

@jreback jreback merged commit e5a99c6 into pandas-dev:master Sep 23, 2018
@jbrockmendel jbrockmendel deleted the ser_idx_bools branch September 25, 2018 23:48
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants