[Numpy-discussion] make hstack and vstack promote 1-D argument to 2-D when necessary
Dr. Phillip M. Feldman
pfeldman at verizon.net
Mon Nov 23 19:43:23 EST 2009
I opened ticket #1302 to make the following enhancement request:
I'd like to see hstack and vstack promote 1-D arguments to 2-D when this is
necessary to make the dimensions match. In the following example, c_ works
as expected while hstack does not:
[~]|8> x
<8>
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
[~]|9> y
<9> array([10, 11, 12])
[~]|10> c_[x,y]
<10>
array([[ 1, 2, 3, 10],
[ 4, 5, 6, 11],
[ 7, 8, 9, 12]])
[~]|11> x
<11>
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
[~]|12> y
<12> array([10, 11, 12])
[~]|13> hstack((x,y))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
\<ipython console> in <module>()
C:\Program Files\Python25\lib\site-packages\numpy\lib\shape_base.pyc in
hstack(tup)
503
504 """
--> 505 return _nx.concatenate(map(atleast_1d,tup),1)
506
507 row_stack = vstack
ValueError: arrays must have same number of dimensions
--
View this message in context: http://old.nabble.com/make-hstack-and-vstack-promote-1-D-argument-to-2-D-when-necessary-tp26488748p26488748.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.
More information about the NumPy-Discussion
mailing list