Skip to content

CLN: always dispatch-to-series #34286

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 10 commits into from
May 23, 2020
Merged

CLN: always dispatch-to-series #34286

merged 10 commits into from
May 23, 2020

Conversation

jbrockmendel
Copy link
Member

A couple more cleanups follow this.

@@ -624,7 +629,7 @@ def to_series(right):


def _should_reindex_frame_op(
left: "DataFrame", right, op, axis, default_axis: int, fill_value, level
left: "DataFrame", right, op, axis, default_axis, fill_value, level
Copy link
Member

Choose a reason for hiding this comment

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

why is this changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

without this i got mypy complaints that i havent been able to track down

Copy link
Member

Choose a reason for hiding this comment

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

Can you share the error message?

Copy link
Member Author

Choose a reason for hiding this comment

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

pandas/core/ops/__init__.py:706: error: Argument 5 to "_should_reindex_frame_op" has incompatible type "Optional[str]"; expected "int"

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha. Looks like _get_frame_op_default_axis returns an Optional string and that is used as the default argument in the f function local to _arith_method_FRAME.

So makes sense Mypy would complain about that. Whether the existing annotation is wrong or if its discovering a bug for us I'm not sure

Copy link
Member Author

Choose a reason for hiding this comment

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

i think its the annotation. there is some more code that can be ripped out after this, so im planning to do an annotation pass towards the end

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Generally looks good, few small questions/comments

assert left.index.equals(right.index)
assert left.columns.equals(right.columns)
# TODO: The previous assertion `assert right._indexed_same(left)`
# fails in cases with shaoe[1] == 0
Copy link
Member

Choose a reason for hiding this comment

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

I don't really understand this comment

Copy link
Member Author

Choose a reason for hiding this comment

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

im finding cases where left.columns and right.columns are both empty but different dtypes, which still satisfy left.columns.equals(right.columns), but not right._indexed_same(left). looks like this is an artifact of the intersection done in _should_reindex_frame_op, looking into this now. (also will fix the typo shaoe -> shape)


elif isinstance(other, ABCSeries):
# For these values of `axis`, we end up dispatching to Series op,
# so do not want the masked op.
# TODO: the above comment is no longer accurate since we now
# operate blockwise if other._values is an ndarray
Copy link
Member

Choose a reason for hiding this comment

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

Can you update the comment instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

simpler to do this in the next pass, which will make us always pass the same thing, at which point we can remove the comment entirely

"""
if isinstance(op, partial):
# We get here via dispatch_to_series in DataFrame case
# TODO: avoid getting here
Copy link
Member

Choose a reason for hiding this comment

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

What is an example with which you get 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.

In _arith_method_FRAME we pass na_op (which is one a partial returned by this function here) to _combine_frame, which in turn passes na_op to dispatch_to_series, which then passes na_op back to this function

@jreback jreback added this to the 1.1 milestone May 22, 2020
@@ -680,11 +685,12 @@ def _frame_arith_method_with_reindex(


def _arith_method_FRAME(cls, op, special):
# This is the only function where `special` can be either True or False
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 type if possible

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@jbrockmendel jbrockmendel added the Numeric Operations Arithmetic, Comparison, and Logical operations label May 22, 2020
@jreback
Copy link
Contributor

jreback commented May 22, 2020

ahh need to rebase

@jbrockmendel
Copy link
Member Author

Looks like the combination of #34324+#34323 have a subtle merge conflict that broke master. this should be fixed by any of my just-rebased PRs

@jreback
Copy link
Contributor

jreback commented May 23, 2020

kk ping when ready in one

@jbrockmendel
Copy link
Member Author

pseudo-green. the remaining CI fail is anoteher ipython directive thing in the docbuild

@jreback jreback merged commit 89f8af7 into pandas-dev:master May 23, 2020
@jreback
Copy link
Contributor

jreback commented May 23, 2020

thanks

if u wouldn’t mind pushing a change for the doc thing

@jbrockmendel jbrockmendel deleted the ref-ops branch May 23, 2020 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants