
the columns of the input array become the columns of the output array. For axis=1, the arrays are concatenated horizontally i.e.the rows of different arrays become the rows of the output array. For axis=0, the rows of the different arrays are concatenated vertically i.e.The axis along which the input arrays are concatenated is decided using the axis parameter.After execution, it returns the concatenated array. Similar to column_stack with the additional ability to use slices.Here, the concatenate() function takes a tuple of numpy arrays as its first input argument. """Translates slice objects to column-wise concatenation. Similar to hstack with the additional ability to use slices. """Translates slice objects to horizontal concatenation. Similar to vstack with the additional ability to use slices.Ĭoncatenator._init_(self, 0, numpy.atleast_2d) """Translates slice objects to vertical (row-wise) concatenation. # Now if you want to make a row, h_ is the way to do it. # but the old c_ could also be used for this purpose. # Note that r_ was used both for 'making a row' and for 'stacking rows' previously, # c_ - like column_stack (the modified version above) # r_ - like row_stack (but row_stack=vstack, so r_=v_) because otherwise we couldn't get the doc string to come out right # separate classes are used here instead of just making r_ = concatentor(0), Res = _nx.concatenate(tuple(objs),axis=self.axis) If isinstance(newobj, _nx.ndarray) and not scalar: Raise ValueError, "unknown special directive" Newobj = numpy.linspace(start, stop, num=size) #newobj = function_base.linspace(start, stop, num=size) Mymat = matrix.bmat(key,frame.f_globals,frame.f_locals) """Translates slice objects to concatenation along an axis.ĭef _init_(self, axis=0, mapping=None, matrix=False): # Makes it so concatenator can generate results like vstack and atleast_2d) before calling concatenate(). This allows for running the data through a # Only difference is the addition of 'mapper' parameter and # Slightly modified version of _ncatenator Just like with hstack, 1D arrays are turned into 2D columns first. Take a sequence of 1D and 2D arrays and stack them as columns """ Stack 1D arrays as columns into a 2D array It's probably a row for a reason, and you should transpose itĪrr = numpy.array(v,copy=False,subok=True) (Q: Should this also transpose any (1xN)'s to be columns? TheĬurrent thinking is if you have a 1-d then you haven't reallyĭecided whether it's a row or col, and this method is asserting """Turns 1-d inputs into a column vectors.įor all other inputs acts like atleast_2d. # ascol helper function to convert only 1d inputs to columns. So you haveįrom import asarray, ScalarType R_ is mostly like vstack, but a little different since it effectively That'sįor r_ and c_ I'm summarizing, but effectively they seem to be doingĬoncatenate( map(atleast_1d,args),axis=0 )Ĭoncatenate( map(atleast_1d,args),axis=-1 )Ĭ_ behaves almost exactly like hstack - with the addition of range
#Numpy vstack self code
The above 3 are pretty much exactly the code used by numpy.


The current docstring only claims that it works with 1d inputs, so making it do something reasonable with 2d inputs will hopefully not break much code.) (note that column_stack transposes everything not just 1-d inputs. Here's essentially what these different methods do:Ĭoncatenate( map(atleast_2d,tup), axis=0 )Ĭoncatenate( map(atleast_1d,tup),axis=1 )Īrrays = map( transpose,map(atleast_2d,tup) ) make a new vertsion of 'c_' that acts like column_stack and make r_ an alias for v_ (just as row_stack is an alias for vstack) so that theres a nice parallel v_vstack, h_hstack, c_column_stack, r_row_stack.rename r_,c_ to v_,h_ (or something else) to make their connection with vstack and hstack clearer.make column_stack only transpose its 1d inputs.
#Numpy vstack self plus
