Skip to content

CLN: trim unreachable indexing code #31768

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
Feb 9, 2020

Conversation

jbrockmendel
Copy link
Member

make _set_value not return anything (the DataFrame docstring in particular is misleading)

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.

This is all just internal right?

@@ -1070,7 +1065,7 @@ def _set_with(self, key, value):

def _set_labels(self, key, value):
key = com.asarray_tuplesafe(key)
indexer = self.index.get_indexer(key)
indexer: np.ndarray = self.index.get_indexer(key)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't need to annotate like this; if anything should set the return of get_indexer to np.ndarray

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, im trying to pin down what gets passed to _set_values below. The check on L1075 is never True, so id like to see if we can rip it out

@WillAyd WillAyd added the Clean label Feb 7, 2020
@jbrockmendel
Copy link
Member Author

This is all just internal right?

Yes

@jreback jreback added this to the 1.1 milestone Feb 9, 2020
@jreback jreback added the Indexing Related to indexing on series/frames, not to indexes themselves label Feb 9, 2020
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.

small assert; i think you can do it in this PR. ping on green.

@@ -902,7 +902,7 @@ def _get_with(self, key):
return self._get_values(key)
raise

if not isinstance(key, (list, np.ndarray, Series, Index)):
if not isinstance(key, (list, np.ndarray, ExtensionArray, Series, Index)):
Copy link
Contributor

Choose a reason for hiding this comment

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

we likely don't have many tests which do this on EAs FYI

assert res.index[-1] == "foobar"
assert res._get_value("foobar", "B") == 0
float_frame._set_value("foobar", "B", 0)
assert float_frame.index[-1] == "foobar"
Copy link
Contributor

Choose a reason for hiding this comment

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

you could assert the return value is None

assert res is s
assert res.index[-1] == "foobar"
assert res["foobar"] == 0
s._set_value("foobar", 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, assert return value is None

@jbrockmendel
Copy link
Member Author

ping

@jreback jreback merged commit c5fb994 into pandas-dev:master Feb 9, 2020
@jreback
Copy link
Contributor

jreback commented Feb 9, 2020

thanks

@jbrockmendel jbrockmendel deleted the unreachable branch February 9, 2020 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants