-
-
Notifications
You must be signed in to change notification settings - Fork 11k
ENH: add block() function to create block arrays #5057
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
Conversation
Being as cynical as I am, how does this play together with all the other stacking functions ;)? What I mean is, can you write to the mailing list as usual, because it is a new function, plus I think we can probably find a better name. Another thing I think, we limit the outer scope to list/tuple explicitly anyway (not much choice there I guess), so if we add it, maybe make it N-dimensional? |
Oh, about doctests... Those are not run currently, so not sure if they are sufficient, but add them as normal tests too at least. (Since I like at least some failure tests often, there probably should be a few more tests anyway) |
By the way, this looks similar to bmat. |
How would anyone know, none of the devs use matrices ;) |
This would explain why numpy/scipy functions related to |
I think that is mostly because of the intrinsic problems with matrices if you don't want to constantly check matrices explicitly... But enough for that. |
Why? They sure look like rows when printed: In [8]: np.arange(10) |
I updated my PR. Because of the discussion here #5605 I renamed the function to Some remarks:
Feedback welcome! |
@abalkin it's just my personal pet I guess :) It does not really matter for the pull request. |
Do you think this is ready to be merged? |
`block` is similar to Matlab's square bracket stacking functionality for block matices. `block` is an addition to the current stacking functions vstack, hstack, stack.
One of my new year's resolution is to get my pull requests merged. So, what do you think? |
Sorry that this didn't get reviewed yet Stefan. It seems useful to multiple people and isn't hard to review, so let's make sure we have a serious look before the next release (I gave it the 1.12.0 milestone). |
""" | ||
Create block arrays similar to Matlab's "square bracket stacking": | ||
|
||
[A A; B B] |
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.
Can you hide this somewhere in the Notes section? Putting Matlab syntax here so prominently feels wrong, plus for a minute I read this as the Python syntax to use.
I can't see the forest for the trees so I talked to my rubber duck. What do we expect? Do we want If we use Now, I'm actually inclined to use |
@sotte Take a look at the commit message guidelines: |
@charris I guess I'm too late. Thanks a lot! Was a lot of fun...as always! |
block
is similar to matlab's "square bracket stacking" functionality:[A B; C D]
.So you can write:
The one thing I'm not super happy with is that 1-D arrays are treated as row vectors and I personally think of them as column vectors.
Are the doctests sufficient or should I create proper unittests?