Skip to content

Continue de-nesting core.ops #19448

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 5 commits into from
Feb 2, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
kludge for long-broken issue
  • Loading branch information
jbrockmendel committed Jan 30, 2018
commit fb6f5349293bcdd4dcf1a12b89cc8464896a2ed1
6 changes: 6 additions & 0 deletions pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,12 @@ def na_op(x, y):
mask = notna(xrav) & notna(yrav)
xrav = xrav[mask]

if yrav.shape != mask.shape:
# FIXME: GH#5284, GH#5035, GH#19448
Copy link
Contributor

Choose a reason for hiding this comment

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

tests that hit this

Copy link
Member Author

Choose a reason for hiding this comment

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

See #19421. Only one test hits this, and only in py3:

s = Series([2, 3, 4, 5, 6, 7, 8, 9, datetime(2005, 1, 1)])
s[::2] = np.nan
d = DataFrame({'A': s})

with pytest.raises(ValueError):
    d.__and__(s, axis='columns')

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a change and not just a refactor. As per the comments, it is horribly broken, and better to raise intentionally than accidentally have the yrav.item() raise a ValueError.

# Without specifically raising here we get mismatched
# errors in Py3 (TypeError) vs Py2 (ValueError)
raise ValueError('Cannot broadcast operands together.')

yrav = yrav[mask]
if xrav.size:
with np.errstate(all='ignore'):
Expand Down