Skip to content

REF: avoid getattr pattern for rank_1d, rank_2d #29137

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 4 commits into from
Oct 22, 2019

Conversation

jbrockmendel
Copy link
Member

Also fix incorrectly-typed nobs in libgroupby

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

these definitely read a lot nicer

@@ -455,7 +455,7 @@ def _group_add(complexfloating_t[:, :] out,
if len(values) != len(labels):
raise ValueError("len(index) != len(labels)")

nobs = np.zeros((len(out), out.shape[1]), dtype=np.int64)
nobs = np.zeros((<object>out).shape, dtype=np.int64)
Copy link
Member

Choose a reason for hiding this comment

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

What does the object cast buy us here?

Copy link
Member Author

Choose a reason for hiding this comment

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

https://groups.google.com/forum/#!topic/cython-users/xheRGGOiuYw

For reasons unknown, out.shape is evaluated as an 8-tuple instead of 2-tuple, and this call raises at runtime without the <object> cast. That's the reason why the status quo doesn't use out.shape directly on L458.

Copy link
Member

Choose a reason for hiding this comment

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

Pretty interesting...and cast to object here doesn't trigger any underlying functions? Not sure if it just changes the type of pointer Cython uses or if it actually changes the memview

@WillAyd WillAyd added the Clean label Oct 22, 2019
@jreback jreback added this to the 1.0 milestone Oct 22, 2019
@jreback jreback merged commit 3188f77 into pandas-dev:master Oct 22, 2019
@jreback
Copy link
Contributor

jreback commented Oct 22, 2019

thanks @jbrockmendel yes nice cleanup

@jbrockmendel jbrockmendel deleted the cylookups branch October 22, 2019 15:09
HawkinsBA pushed a commit to HawkinsBA/pandas that referenced this pull request Oct 29, 2019
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
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants