Here's the best I can see:
>>> a = eye(2,2)
>>> b = 2*a
>>> c = 3*a
>>> d = 4*a
>>> r_[c_[a,b],c_[c,d]]
array([[1, 0, 2, 0],
[0, 1, 0, 2],
[3, 0, 4, 0],
[0, 3, 0, 4]])
In matlab you'd get the same effect by saying: [ a, b; c, d ]
Compared to that, r_[c_[a,b],c_[c,d]] looks quite a mess.
Would be nice if there were some operator like c_ that took a special argument that introduced a new row. Like maybe:
c_[a,b, newrow, c,d]
or maybe you could abuse the syntax and make something like this work:
c_[a,b : c,d]
or perhaps an empty argument could work?
c_[a,b ,, c,d]
Or empty tuple:
c_[a,b, (), c,d]
Hmm... I see there's already something in the code for handling 'special directives':
>>> c_[a,b,'r',c,d]
matrix([[1, 0, 2, 0, 3, 0, 4, 0],
[0, 1, 0, 2, 0, 3, 0, 4]])
'r' seems to turn the results into a matrix. Maybe that could be used to recognize a newline or something:
>>> c_[a,b,'\n',c,d]
Traceback (most recent call last):
File "<input>", line 1, in ?
File "C:\Python24\Lib\site-packages\numpy\lib\index_tricks.py", line 239, in __getitem__
raise ValueError, "Unknown special directive."
ValueError: Unknown special directive.
--Bill
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Numpy-discussion mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/numpy-discussion
