Skip to content

Assorted cleanups #27376

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 7 commits into from
Jul 15, 2019
Merged

Assorted cleanups #27376

merged 7 commits into from
Jul 15, 2019

Conversation

jbrockmendel
Copy link
Member

The only noticeable thing should be a couple of fixed build warnings from khash_python

new_values = algos.take_nd(
values, indexer, axis=axis, allow_fill=True, fill_value=fill_value
)
allow_fill = True
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 the ExtensionBlock.take_nd method we have this same if/elif for fill_tuple/fill_value, but we don't set allow_fill there. Seems fishy. @jorisvandenbossche any idea if this is intentional?

Copy link
Member

Choose a reason for hiding this comment

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

Do you know for what case the allow_fill=False branch gets hit?

In the end, I think this is only an optimization for when you know that there are no -1's in the indexer. Because in the internals, I think we never use the numpy-like indexing semantics of -1 meaning the last element.

@@ -1408,7 +1408,7 @@ def __getitem__(self, key):
maybe_callable = com.apply_if_callable(key, self.obj)
return self._getitem_axis(maybe_callable, axis=axis)

def _is_scalar_access(self, key):
def _is_scalar_access(self, key: tuple):
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 use Tuple from typing module and annotate types contained within 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.

will do


# Called from three places in managers, all of which satisfy
# this assertion
assert not (axis == 0 and new_mgr_locs is None)
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 raise a ValueError here instead of using assert? In the off chance someone uses -O flag assert won't help

Copy link
Contributor

Choose a reason for hiding this comment

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

asserts are ok in the internals

@WillAyd WillAyd added the Clean label Jul 15, 2019
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.

just need the tuple change

@jreback jreback added the Internals Related to non-user accessible pandas implementation label Jul 15, 2019
@jbrockmendel
Copy link
Member Author

tuple change made

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.

lgtm comment on typing I don't think critical but food for thought if possible

@@ -1408,7 +1409,7 @@ def __getitem__(self, key):
maybe_callable = com.apply_if_callable(key, self.obj)
return self._getitem_axis(maybe_callable, axis=axis)

def _is_scalar_access(self, key):
def _is_scalar_access(self, key: Tuple):
Copy link
Member

Choose a reason for hiding this comment

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

Length here is always indeterminate right? If it is predefined would be nice to subscript with the length of elements

Copy link
Member Author

Choose a reason for hiding this comment

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

Yah, in general we don't know the length.

I'll be doing some more work in this file, will try to make types more specific as I figure them out

@jbrockmendel
Copy link
Member Author

anything else needed here?

@jreback jreback added this to the 0.25.0 milestone Jul 15, 2019
@jreback jreback merged commit 4dd2e3f into pandas-dev:master Jul 15, 2019
@jreback
Copy link
Contributor

jreback commented Jul 15, 2019

thanks!

@jbrockmendel jbrockmendel deleted the upnext2 branch July 15, 2019 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants