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

REF: boilerplate for ops internal consistency #28037

Merged
merged 57 commits into from
Nov 14, 2019

Conversation

jbrockmendel
Copy link
Member

Progress towards #23853, with more progress available pending resolution of #27911.

@jbrockmendel
Copy link
Member Author

An option for the future could make the op_name arg unnecessary (and therefore the separate steps unpack_and_defer -> _unpack_and_defer) by pinning it for the subset of methods for which it is not already correct:

@unpack_and_defer
@rename(op_name)
def generated_func(self, other): ...

instead of

@unpack_and_defer(op_name)
def generated_func(self, other): ...

def new_method(self, other):

if is_cmp and isinstance(self, ABCIndexClass) and isinstance(other, ABCSeries):
# For comparison ops, Index does *not* defer to Series
Copy link
Member

@jorisvandenbossche jorisvandenbossche Sep 18, 2019

Choose a reason for hiding this comment

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

For comparison ops, Index does not defer to Series

Is there a good reason for that, or just another inconsistency that ideally one time should be solved?

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 it has to do with wanting to make idx == ser an ndarray for the sake of ser[idx == ser] but I'm not sure

Copy link
Member

Choose a reason for hiding this comment

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

For this case, ser[idx == ser] would also work when the result is a Series

@jorisvandenbossche
Copy link
Member

Other question for my understanding: the "unpack" in the decorator name, does that point to the unpacking of zerodim array? Or also to (future?) unpacking of Series/Index to array?

@jbrockmendel
Copy link
Member Author

the "unpack" in the decorator name, does that point to the unpacking of zerodim array?

Yes. I'm open to other names if you have a strong preference.

Or also to (future?) unpacking of Series/Index to array?

I hadn't thought of that, but tentatively like it. The main thing I have in mind for extending this in the future is doing a) non-array listlike coercion and b) length-match checks since we're not very consistent about either of these.

@jorisvandenbossche
Copy link
Member

If this is not actually unpacking our containers, I think another name would be better (I actually thought all the time those methods would be for this purpose)

Just unpack_zerodim instead of unpack can already help?

@jbrockmendel
Copy link
Member Author

Just unpack_zerodim instead of unpack can already help?

Sure.

@TomAugspurger TomAugspurger added this to the 1.0 milestone Sep 23, 2019
@jreback
Copy link
Contributor

jreback commented Nov 13, 2019

@jbrockmendel status of this

@jbrockmendel
Copy link
Member Author

status of this

there was a request to name something differently that i need to get around to, otherwise this should be ready (havent rebased in a while, so should do that too)

@jreback
Copy link
Contributor

jreback commented Nov 14, 2019

status of this

there was a request to name something differently that i need to get around to, otherwise this should be ready (havent rebased in a while, so should do that too)

this PR lgtm. I can't find that request, what was it?

@jbrockmendel
Copy link
Member Author

I can't find that request, what was it?

Addressed in a commit yesterday. It was to rename "unpack_and_defer" to "unpack_zerodim_and_defer"

@jreback jreback merged commit 79e1fc3 into pandas-dev:master Nov 14, 2019
@jreback
Copy link
Contributor

jreback commented Nov 14, 2019

thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the opcom branch November 14, 2019 16:36
Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants