-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Simplify _reshape_2D. #8116
Conversation
(I still think iterating over rows vs. over columns depending on input type is rather silly but at least this implementation makes it clearer.)
👍 Test failure looks unrelated. I also notice that |
It is implicitly tested by the various input shapes that tests pass to |
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) |
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.
Why would you behave differently for ndarrays than for any other 2D types? (such as matrices, 2D lists etc.)
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.
See #8092 (comment).
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 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?
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 would even go as far as raising a warning when a list is provided and deprecate the behavior we have with list.
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 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.
@tacaswell can we discuss about this PR tomorrow? |
(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)