Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Simplify _reshape_2D. #8116

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 1 commit into from
Mar 23, 2017
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 21, 2017

(I still think iterating over rows vs. over columns depending on input
type is rather silly but at least this implementation makes it clearer.)

(Written while working on #8092, attn @phobson)

(I still think iterating over rows vs. over columns depending on input
type is rather silly but at least this implementation makes it clearer.)
@phobson
Copy link
Member

phobson commented Feb 21, 2017

👍 Test failure looks unrelated.

I also notice that _reshape_2d doesn't have any of its own tests. I can take a stab at those and push to this PR if you want.

@anntzer
Copy link
Contributor Author

anntzer commented Feb 21, 2017

It is implicitly tested by the various input shapes that tests pass to boxplot (which includes 2D array, ragged arrays and whatever weirdness).

@dstansby dstansby added this to the 2.1 (next point release) milestone Mar 1, 2017
@dstansby dstansby changed the title Simplify _reshape_2D. [MRG+1] Simplify _reshape_2D. Mar 1, 2017
if not hasattr(X[0], '__len__'):
X = [X]
# Iterate over columns for ndarrays, over rows otherwise.
X = X.T if isinstance(X, np.ndarray) else np.asarray(X)
Copy link
Member

Choose a reason for hiding this comment

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

Why would you behave differently for ndarrays than for any other 2D types? (such as matrices, 2D lists etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I feel very uncomfortable with having such a behavior in something that could be easily called in functions where we wouldn't want this behaviour. Is it possible to rename this function to something like _fundamentally_broken_reshape_2D and have a huge warning in the documentation?

Copy link
Member

Choose a reason for hiding this comment

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

I would even go as far as raising a warning when a list is provided and deprecate the behavior we have with list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you, but I think these should be a separate issue. The only point of this PR is to deobfuscate the implementation of this function.

I think it is important to keep the ability to pass lists in -- it is natural to plot boxplots with unequal sized datasets, and you can't do that with a 2D array.

@NelleV NelleV requested a review from tacaswell March 15, 2017 21:55
@NelleV
Copy link
Member

NelleV commented Mar 20, 2017

@tacaswell can we discuss about this PR tomorrow?

@NelleV NelleV merged commit 6060a40 into matplotlib:master Mar 23, 2017
@QuLogic QuLogic changed the title [MRG+1] Simplify _reshape_2D. Simplify _reshape_2D. Mar 23, 2017
@anntzer anntzer deleted the simplify-_reshape_2D branch March 24, 2017 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants