[Numpy-discussion] numpy.stack -- which function, if any, deserves the name?

Nathaniel Smith njs at pobox.com
Mon Mar 16 04:57:52 EDT 2015

We already use the word "stack" in lots of function names to refer to
something different from what bmat does. So while I definitely agree we
should have something like bmat for ndarrays, it would be better all the to
just pick a different name. np.block, even, might do the job.

On Mar 16, 2015 1:50 AM, "Stefan Otte" <stefan.otte at gmail.com> wrote:
> Hey,
> > 1. np.stack for stacking like np.asarray(np.bmat(...))
> > http://thread.gmane.org/gmane.comp.python.numeric.general/58748/
> > https://github.com/numpy/numpy/pull/5057
> I'm the author of this proposal. I'll just give some context real quickly.
> "My stack" started really simple, basically allowing a Matlab-like
> notation for stacking:
> matlab: [ a b; c d ]
> numpy: stack([[a, b], [c, d]]) or even stack([a, b], [c, d])
> where a, b, c, and d a arrays.
> During the discussion people asked for fancier stacking and auto
> filling of non explicitly set blocks (think of an "eye" matrix where
> only certain blocks are set).
> Alternatively, we thought of refactoring the core of bmat [2] so that
> it can be used with arrays and matrices. This would allow stack("a b;
> c d") where a, b, c, and d are the names of arrays/matrices. (Also
> bmat would get better documentation during the refactoring :)).
> Summarizing, my proposal is mostly concerned how to create block
> arrays from given arrays. I don't care about the name "stack". I just
> used "stack" because it replaced hstack/vstack for me. Maybe "bstack"
> for block stack, or "barray" for block array?
> I have the feeling [1] that my use case is more common, but I like the
> second proposal.
> Cheers,
>  Stefan
> [1] Everybody generalizes from oneself. At least I do.
> [2] http://docs.scipy.org/doc/numpy/reference/generated/numpy.bmat.html
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150316/967f4076/attachment.html>

More information about the NumPy-Discussion mailing list