Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
FIX: pandas indexing error#5556
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
@@ -1561,7 +1561,7 @@ def default_units(x, axis): | |||
x = x.ravel() | |||
try: | |||
x =x[0] | |||
x =next(iter(x)) | |||
except (TypeError, IndexError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
line1565
should be modified to
except (TypeError,StopIteration):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for catching that!
50b547c
to825f613
Comparerebased. |
Also addresses#5557 |
---------- | ||
inp : iterable | ||
ename : str, optional | ||
Name to use is ValueError if can not be normalized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
"is" --> "in"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I swear I know english...
besides the nitpicking, this looks good to me |
@WeatherGod do you want me to drop that (some what superfluous) white space commit? |
Eh, might be better to get rid of that commented out code entirely. I don't see the point of keeping it around. |
Well, the minimum numpy is now 1.6 so we should do what ever it was that note was telling us to do. |
? |
The comment below the commented line says that we are handling |
Ah, yeah, that comment (I must be getting blind...). I suspect that it is quite old and came from before the days that stacked histograms and such were possible. I am not sure it is possible to just hand off the responsibility of norming to numpy any more given the current feature set. |
6ec1bbd
tof0a8a02
Comparepd.Series prefer indexing via searching the index to positionalindexing. This method will get the first element of any iterable.It will advance a generater, but they did not work previously anyway.Closesmatplotlib#5550
using `next(iter(obj))` can raise `TypeError` if obj is not iterableand `StopIteration` if len(obj) == 0. As we are no longer explictilyindexing into `obj` it should not raise an `IndexError`
Both iterable and index_of are imported at the top of this import block
f0a8a02
tobb7691b
CompareThis is passing and not conflicting, can someone push the button on this before it needs another rebase 😈 . |
I do have another concern with respect to generators. Previously, generators just simply didn't work, now they may sort of work (generator gets partly consumed). This muddles the API a bit. Wouldn't it be better to detect that we have a generator and raise an error? We can later consider how to properly support generators without consuming them. |
That is a can of worms of handling I am worried about opening and would rather punt on the whole thing. This at least does notbreak any existing user code. |
isn't it just simply a matter of testing |
I am more worried about applying that test uniformly across the library. |
That would be nice, but it is not the goal that I am seeking. Simply that we add this test where-ever we have code that would potentially consume an iterator. That way, the API hasn't changed. So, that is just two places here in this PR. |
fair enough |
All versions of python we support have built in `next`
- moved next(iter(obj)) logic into a cbook function
Digging into this a bit (and trying to sort out why This PR is a whack-a-mole fix which will get 1.5.1 out the door. |
The test failure is un-related (due to backport of custom RNG). |
seems like it, was the baseline images not updated for the new RNG? |
They were. This looks like a "only on Travis" sort of failure. |
That doesn't give me any sort of warm fuzzies... |
I can reproduce it locally (but it passedbefore I pushed upstream (which I assume means my local install had become screwed up)). |
I hope this hasn't become another rabbit-infested dragon cave... |
Looks like you cleared out the rabbits! |
By moving a bit of the if-statement into a cbook function, the if-statement starts to be a little bit clearer. Probably would be a good idea to have some cbook tests at some point, but that can come later. |
Specifically, when creating collection objects,`linewidths` and `antialiaseds` can be non zero indexedpandas series.Related to: PR#5556
This was unintentionally broken bybdaaf59 which went in as part ofPRmatplotlib#5556 which was fixing support for pandas series.
This was unintentionally broken bybdaaf59 which went in as part ofPRmatplotlib#5556 which was fixing support for pandas series.
pd.Series prefer indexing via searching the index to positional
indexing. This method will get the first element of any iterable.
It will advance a generater, but they did not work previously anyway.
Closes#5550