[Numpy-discussion] r_, c_, hstack, and vstack with 1-d arrays

Sven Schreiber svetosch at gmx.net
Wed Jul 19 09:06:34 EDT 2006


Bill Baxter schrieb:
> For 1-d inputs I think r_ should act like vstack, and c_ should act
> like column_stack.
> Currently r_ and c_ both act like hstack for 1-d inputs.

Well Bill, as I said before, you should have stayed with matrices ;-)
Seriously, I think all the quirks you mentioned recently are now gone.

I mean what you're experiencing now ist just logical from the point of
view that rows and columns are 2d concepts, so a 1d array just isn't enough.

Having said that, however, here are some more constructive comments:

First, I think using c_ is not recommended, it doesn't even appear in
the book. But I have no idea why that is so, I'm using it also (with
matrices), so I think it's valid to question that deprecation. Indeed it
seems natural to make it act like column_stack for 1d arrays!?

Second, changing r_ would obviously break some people's codes. Two
workarounds: You switch to matrices (sorry, couldn't resist), or you use
vstack (trivial, sorry again).


> 
> Also isn't it odd that there's a column_stack, but no row_stack?  I
> guess that's because row_stack would just be an alias for vstack, but
> still.
> 

I agree that for the poor non-matrix-users it would be good to have a
pair of names that obviously belong together, instead of the current
vstack/column_stack situation; with matrices you have the choice of
r_/c_ or vstack/hstack that do exactly what you want (as you know).

Good luck,
Sven




More information about the NumPy-Discussion mailing list