|
From: Travis O. <oli...@ee...> - 2006-02-10 22:28:42
|
Christopher Barker wrote: > Colin J. Williams wrote: > >>> numpy.r_[1,0,range(1,5),0,1] >> > >> This seems to be a neat idea but not in the usual Python style. > > > Exactly. couldn't it at least get a meaningful, but short, name? It is meaningful :-) r_ means row concatenation... (but, it has taken on more functionality than that). What name do you suggest? > > And is there a way to use it to concatenate along other axis? I > couldn't see a way. Yes, add a string at the end with the number of the axis you want to concatenate along. But, you have to have that axis to start with or the result is no different. The default is to concatenate along the last axis. Thus (the ndmin keyword forces the array to have a minimum number of dimensions --- prepended). a = array([1,2,3],ndmin=2) b = array([1,2,3],ndmin=2) c = r_[a,b,'0'] print c [[1 2 3] [1 2 3]] print r_[a,b,'1'] [[1 2 3 1 2 3]] -Travis |