A generic n-dimensional array class using nested lists for storage.
Arrays can be built from numeric values, iterables, nested lists or other Array instances
>>> Array()
Array([])
>>> Array(2)
Array([2])
>>> A = Array([[1, 2], [3, 4]])
>>> print A.formated()
[[1, 2],
[3, 4]]
>>> A = Array([1, 2], [3, 4])
>>> print A.formated()
[[1, 2],
[3, 4]]
>>> A = Array([[1, 2]])
>>> print A.formated()
[[1, 2]]
>>> A = Array([1], [2], [3])
>>> print A.formated()
[[1],
[2],
[3]]
>>> A = Array([[[1], [2], [3]]])
>>> print A.formated()
[[[1],
[2],
[3]]]
You can query some Array characteristics with the properties shape, ndim (number of dimensions) and size, the total number of numeric components
>>> A = Array(range(1, 10), shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> A.shape
(3, 3)
>>> A.ndim
2
>>> A.size
9
Arrays are stored as nested lists and derive from the ‘list’ class.
>>> A.data
[Array([1, 2, 3]), Array([4, 5, 6]), Array([7, 8, 9])]
>>> list(A)
[Array([1, 2, 3]), Array([4, 5, 6]), Array([7, 8, 9])]
Initialization from another Array does a shallow copy, not a deepcopy, unless the Array argument is resized / reshaped.
>>> B = Array(A)
>>> print B.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> B == A
True
>>> B is A
False
>>> B[0] is A[0]
True
>>> C = Array([A])
>>> print C.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]]
>>> C[0] is A
True
>>> C[0,0] is A[0]
True
You can pass optional shape information at creation with the keyword arguments shape, ndim and size. The provided data will be expanded to fit the desirable shape, either repeating it if it’s a valid sub-array of the requested shape, or padding it with the Array default value (0 unless defined otherwise in an Array sub-class).
Value will be repeated if it is a valid sub-array of the Array requested
>>> A = Array(1, shape=(2, 2))
>>> print A.formated()
[[1, 1],
[1, 1]]
It will be padded otherwise, with the Array class default value
>>> A = Array(1, 2, shape=(4,))
>>> print A.formated()
[1, 2, 0, 0]
Or a combination of both, first pad it to a valid sub-array then repeat it
>>> A = Array(1, 2, shape=(3, 3))
>>> print A.formated()
[[1, 2, 0],
[1, 2, 0],
[1, 2, 0]]
Repeat can occur in any dimension
>>> A = Array([1, 2, 3], shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[1, 2, 3],
[1, 2, 3]]
TODO : #>>> A = Array([[1], [2], [3]], shape=(3, 3)) #>>> print A.formated() #[[1, 1, 1], # [2, 2, 2], # [3, 3, 3]]
To avoid repetition, you can use a nested list of the desired number of dimensions
>>> A = Array([1,2,3], shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[1, 2, 3],
[1, 2, 3]]
>>> A = Array([[1,2,3]], shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[0, 0, 0],
[0, 0, 0]]
If sub-array and requested array have same number of dimensions, padding with row / columns will be used (useful for the MatrixN sub-class or Array)
>>> A = Array(range(1, 10), shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> B = Array(A, shape=(4, 4))
>>> print B.formated()
[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 0]]
Initialization will not allow to truncate data, if you provide more arguments than the requested array shape can fit, it will raise an exception. Use an explicit trim / resize or item indexing if you want to extract a sub-array
>>> A = Array([1, 2, 3, 4, 5], shape=(2, 2))
Traceback (most recent call last):
...
TypeError: cannot initialize a Array of shape (2, 2) from [1, 2, 3, 4, 5] of shape (5,),
as it would truncate data or reduce the number of dimensions
a.all([axis0[, axis1[, ...]]]) <=> all(a, axis=(axis0, axis1, ...))
Returns True if all the components of iterable a evaluate to True. If axis are specified will return an Array of all(x) for x in a.axisiter(*axis).
>>> A = Array([[True,True,True],[False,True,False]])
>>> print A.formated()
[[True, True, True],
[False, True, False]]
>>> A.all()
False
>>> A.all(0, 1)
False
>>> A.all(0)
Array([False, True, False])
>>> A.all(1)
Array([True, False])
a.any([axis0[, axis1[, ...]]]) <=> any(a, axis=(axis0, axis1, ...))
Returns True if any of the components of iterable a evaluate to True. If axis are specified will return an Array of any(x) for x in a.axisiter(*axis).
>>> A = Array([[False,True,True],[False,True,False]])
>>> print A.formated()
[[False, True, True],
[False, True, False]]
>>> A.any()
True
>>> A.any(0, 1)
True
>>> A.any(0)
Array([False, True, True])
>>> A.any(1)
Array([True, True])
a.append(b[, axis=0])
Modifies a by appending b at its end, as iterated on axis.
Note : does not work as list append and appends a copy (deepcopy) of b, not a reference to b. However a is appended in place.
Examples:
>>> A = Array([])
>>> print repr(A)
Array([])
>>> A.append(1)
>>> print A.formated()
[1]
>>> A.append(2)
>>> print A.formated()
[1, 2]
>>> A = Array([A])
>>> print A.formated()
[[1, 2]]
>>> A.append([4, 5], axis=0)
>>> print A.formated()
[[1, 2],
[4, 5]]
>>> A.append([3, 6], axis=1)
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6]]
>>> A.append([7, 8, 9])
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> B = Array([A])
>>> B.append(A)
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]]
>>> B[0] == B[1]
True
>>> B[0] is B[1]
False
>>> A == B[0]
True
>>> A is B[0]
True
>>> B.append([0, 0, 0], axis=1)
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]],
<BLANKLINE>
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]]]
>>> B.append([0, 0, 0, 1], axis=2)
>>> print B.formated()
[[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 1]],
<BLANKLINE>
[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 1]]]
a.appended(b[, axis=0]) –> Array
Returns the Array obtained by appending b at the end of a as iterated on axis.
Note : returns a deepcopy of a.appends(b[, axis=0]).
Examples:
>>> A = Array([])
>>> print repr(A)
Array([])
>>> A = A.appended(1)
>>> print A.formated()
[1]
>>> A = A.appended(2)
>>> print A.formated()
[1, 2]
>>> A = Array([A])
>>> print A.formated()
[[1, 2]]
>>> A = A.appended([4, 5], axis=0)
>>> print A.formated()
[[1, 2],
[4, 5]]
>>> A = A.appended([3, 6], axis=1)
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6]]
>>> A = A.appended([7, 8, 9])
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> B = Array([A]).appended(A)
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]]
>>> B[0] == B[1]
True
>>> B[0] is B[1]
False
>>> A == B[0]
True
>>> A is B[0]
False
>>> B = B.appended([0, 0, 0], axis=1)
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]],
<BLANKLINE>
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]]]
>>> B = B.appended([0, 0, 0, 1], axis=2)
>>> print B.formated()
[[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 1]],
<BLANKLINE>
[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 1]]]
a.assign(b) –> Array
Assigns the value of b to a, equivalent to using the data property : a.data = b. Besides changing a’s value, it also returns the new a to conform to Maya’s api assign.
Note: assign acts as a shallow copy
>>> A = Array(range(1, 5), shape=(2, 2))
>>> B = Array()
>>> B.assign(A)
Array([[1, 2], [3, 4]])
>>> print B.formated()
[[1, 2],
[3, 4]]
>>> B == A
True
>>> B is A
False
>>> B[0] is A[0]
True
a.axisiter([axis1[, axis2[, ...]]]) –> ArrayIter
Returns an iterator using a specific axis or list of ordered axis. It is equivalent to transposing the Array using these ordered axis and iterating on the new Array for the remaining sub array dimension
Note : ArrayIter ierators support __len__, __getitem__ and __setitem__
>>> A = Array(range(1, 10), shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> [a for a in A]
[Array([1, 2, 3]), Array([4, 5, 6]), Array([7, 8, 9])]
>>> [a for a in A.axisiter(0)]
[Array([1, 2, 3]), Array([4, 5, 6]), Array([7, 8, 9])]
>>> [a for a in A.axisiter(1)]
[Array([1, 4, 7]), Array([2, 5, 8]), Array([3, 6, 9])]
>>> [a for a in A.axisiter(0,1)]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> [a for a in A.axisiter(1,0)]
[1, 4, 7, 2, 5, 8, 3, 6, 9]
a.blend(b[, weight=0.5]) <==> blend(a, b[, weights=0.5])
Returns the result of blending from Array instance u to v according to either a scalar weight where blend will yield a*(1-weight) + b*weight Array, or a an iterable of independent weights.
>>> A = Array(0, shape=(2, 2))
>>> print A.formated()
[[0, 0],
[0, 0]]
>>> B = Array(1, shape=(2, 2))
>>> print B.formated()
[[1, 1],
[1, 1]]
>>> print A.blend(B, weight=0.5).formated()
[[0.5, 0.5],
[0.5, 0.5]]
>>> print blend(A, B).formated()
[[0.5, 0.5],
[0.5, 0.5]]
>>> print blend(A, B, weight=[x/4.0 for x in range(4)]).formated()
[[0.0, 0.25],
[0.5, 0.75]]
>>> print blend(A, B, weight=[[0.0, 0.25],[0.75, 1.0]]).formated()
[[0.0, 0.25],
[0.75, 1.0]]
a.clamp([low=0[, high=1]]) <==> clamp (a, low, high)
Returns the result of clamping each component of a between low and high if low and high are scalars, or the corresponding components of low and high if low and high are sequences of scalars
>>> A = Array(range(4), shape=(2, 2))
>>> print A.formated()
[[0, 1],
[2, 3]]
>>> print A.clamp(1, 2).formated()
[[1, 1],
[2, 2]]
>>> print clamp(A, 1, 2).formated()
[[1, 1],
[2, 2]]
>>> print clamp(A, 0.0, [x/4.0 for x in range(4)]).formated()
[[0, 0.25],
[0.5, 0.75]]
a.conjugate() <==> conjugate(a)
Returns the element-wise complex.conjugate() of the Array.
>>> A = Array([[complex(1, 2), complex(2, 3)], [complex(4, 5), complex(6, 7)]])
>>> print A.formated()
[[(1+2j), (2+3j)],
[(4+5j), (6+7j)]]
>>> print A.conjugate().formated()
[[(1-2j), (2-3j)],
[(4-5j), (6-7j)]]
>>> print conjugate(A).formated()
[[(1-2j), (2-3j)],
[(4-5j), (6-7j)]]
>>> A = Array(range(1, 5), shape=(2, 2))
>>> print conjugate(A).formated()
[[1, 2],
[3, 4]]
a.copy() <==> copy.copy(a)
Returns a shallow copy of a
>>> A = Array(range(1, 10), shape=(3, 3))
>>> B = A.copy()
>>> print B.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> print B == A
True
>>> print B is A
False
>>> print B[0] == A[0]
True
>>> print B[0] is A[0]
True
a.count(b) –> int
Returns the number of occurrences of b in a.
>>> A = Array(list(range(1, 6))+list(range(4, 0, -1)), shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 4],
[3, 2, 1]]
>>> A.count(5)
1
>>> A.count(4)
2
>>> A.count([1, 2, 3])
1
>>> A.count([1, 2])
0
a.deepcopy() <==> copy.deepcopy(a)
Returns a deep copy of a
>>> A = Array(range(1, 10), shape=(3, 3))
>>> B = A.deepcopy()
>>> print B.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> print B == A
True
>>> print B is A
False
>>> print B[0] == A[0]
True
>>> print B[0] is A[0]
False
a.deleted(index) –> Array
Returns a copy (deepcopy) of a with the elements designated by index deleted, as in a.__delitem__(index).
Note : as opposed to a.stripped(index), do not collapse dimensions of the Array that end up with only one sub-array.
>>> A = Array(xrange(1, 28), shape=(3, 3, 3))
>>> print A.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]],
<BLANKLINE>
[[19, 20, 21],
[22, 23, 24],
[25, 26, 27]]]
>>> A.shape
(3, 3, 3)
>>> B = A.deleted(1)
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[19, 20, 21],
[22, 23, 24],
[25, 26, 27]]]
>>> B.shape
(2, 3, 3)
>>> B[0] == A[0]
True
>>> B[0] is A[0]
False
>>> B = B.deleted(-1)
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]]
>>> B.shape
(1, 3, 3)
>>> B = B.deleted(None, None, slice(1, 3))
>>> print B.formated()
[[[1],
[4],
[7]]]
>>> B.shape
(1, 3, 1)
>>> B = B.deleted((None, slice(1, 3)))
>>> print B.formated()
[[[1]]]
>>> B.shape
(1, 1, 1)
>>> B = B.deleted(-1)
>>> print B.formated()
[]
>>> B.shape
(0,)
a.dist(b, axis0, axis1, ...) <==> dist(a, b[, axis=(axis0, axis1, ...)])
Returns the distance between a and b, ie length(b-a, axis)
>>> A = Array([[0.5, 0.5, -0.707],[0.707, -0.707, 0.0]])
>>> print A.formated()
[[0.5, 0.5, -0.707],
[0.707, -0.707, 0.0]]
>>> B = Array([[0.51, 0.49, -0.71],[0.71, -0.70, 0.0]])
>>> print B.formated()
[[0.51, 0.49, -0.71],
[0.71, -0.7, 0.0]]
>>> A.dist(B)
0.016340134638368205
>>> A.dist(B, 0, 1)
0.016340134638368205
>>> A.dist(B, 0)
Array([0.0144568322948, 0.00761577310586])
>>> A.dist(B, 1)
Array([0.0104403065089, 0.0122065556157, 0.003])
a.distanceTo(b) <==> a.dist(b)
Equivalent to the dist method, for compatibility with Maya’s API. Does not take axis arguements
a.vstack(b) <==> a.stack(b, axis=0)
Modifies a by concatenating b at its end, as iterated on first axis. For a 2 dimensional Array/MatrixN, it stacks a and b vertically
>>> A = Array([[1, 2], [3, 4]])
>>> print A.formated()
[[1, 2],
[3, 4]]
>>> A.vstack([[5, 6]])
>>> print A.formated()
[[1, 2],
[3, 4],
[5, 6]]
a.vstacked(b) <==> a.stacked(b, axis=0)
Returns the Array obtained by concatenating a and b on first axis. For a 2 dimensional Array/MatrixN, it stacks a and b vertically.
>>> A = Array([[1, 2], [3, 4]])
>>> print A.formated()
[[1, 2],
[3, 4]]
>>> A = A.vstacked([[5, 6]])
>>> print A.formated()
[[1, 2],
[3, 4],
[5, 6]]
a.fill([value])
Fills the array in place with the given value, if no value is given a is filled with the default class values
Note : value is copied (deepcopy) as many times as it is inserted in a, not referenced.
Examples:
>>> A = Array(shape=(3, 3))
>>> print A.formated()
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
>>> A.fill(10)
>>> print A.formated()
[[10, 10, 10],
[10, 10, 10],
[10, 10, 10]]
>>> A.fill()
>>> print A.formated()
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
>>> A.fill([1, 2])
>>> print A.formated()
[[1, 2, 0],
[1, 2, 0],
[1, 2, 0]]
>>> A.fill([1, 2, 3])
>>> print A.formated()
[[1, 2, 3],
[1, 2, 3],
[1, 2, 3]]
>>> A[0] == A[-1]
True
>>> A[0] is A[-1]
False
a.filled([value]) –> Array
Returns a copy (deepcopy) of a, filled with value for a’s shape. If no value is given, a is filled with the class default. value will be expended with the class default values to the nearest matching sub array of a, then repeated. value can’t be truncated and will raise an error if of a size superior to the size of the nearest matching sub array of the class, to avoid improper casts.
Note : value is copied (deepcopy) as many times as it is inserted in a, not referenced.
Examples:
>>> Array(shape=(5,)).filled([0, 1, 2])
Array([0, 1, 2, 0, 0])
>>> Array(shape=(5,)).filled(2)
Array([2, 2, 2, 2, 2])
>>> print Array(shape=(2, 2)).filled(1).formated()
[[1, 1],
[1, 1]]
>>> A = Array(shape=(3, 3)).filled([1, 2, 3])
>>> print A.formated()
[[1, 2, 3],
[1, 2, 3],
[1, 2, 3]]
>>> A[0] == A[-1]
True
>>> A[0] is A[-1]
False
>>> A = Array(shape=(3, 3)).filled([1, 2])
>>> print A.formated()
[[1, 2, 0],
[1, 2, 0],
[1, 2, 0]]
>>> Array(shape=(2, 2)).filled([1, 2, 3])
Traceback (most recent call last):
...
ValueError: value of shape (3,) cannot be fit in a Array of shape (2, 2), some data would be lost
a.fit(b)
Fits the Array b in a. For every component of a that exists in b (there is a component of same coordinates in b), replace it with the value of the corresponding component in b. Both Arrays a and b must have same number of dimensions.
Note : copies (deepcopy) of b sub-arrays are fit in a, not references, but modification of a is done in-place.
>>> A = Array(range(1, 10), shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> B = Array(shape=(4, 3))
>>> print B.formated()
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
>>> S = B[-1]
>>> B.fit(A)
>>> print B.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]]
>>> B[0] == A[0]
True
>>> B[0] is A[0]
False
>>> S == B[-1]
True
>>> S is B[-1]
True
>>> B = Array(shape=(4, 4))
>>> B.fit(A)
>>> print B.formated()
[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 0]]
>>> B = Array(shape=(2, 2))
>>> B.fit(A)
>>> print B.formated()
[[1, 2],
[4, 5]]
a.fitted(b) –> Array
Returns the result of fitting the Array b in a. For every component of a that exists in b (there is a component of same coordinates in b), replace it with the value of the corresponding component in b. Both Arrays a and b must have same number of dimensions.
Note : returns a copy (deepcopy) of a.fit(b)
>>> A = Array(range(1, 10), shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> B = Array(shape=(4, 3))
>>> print B.formated()
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
>>> C = B.fitted(A)
>>> print C.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]]
>>> C[0] == A[0]
True
>>> C[0] is A[0]
False
>>> C[-1] == B[-1]
True
>>> C[-1] is B[-1]
False
>>> B = Array(shape=(4, 4)).fitted(A)
>>> print B.formated()
[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 0]]
>>> B = Array(shape=(2, 2)).fitted(A)
>>> print B.formated()
[[1, 2],
[4, 5]]
a.flat –> ArrayIter
Flat iterator on all components of the Array
Note : ArrayIter iterators support __len__, __getitem__ and __setitem__
>>> A = Array(range(1, 10), shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> [a for a in A]
[Array([1, 2, 3]), Array([4, 5, 6]), Array([7, 8, 9])]
>>> [a for a in A.flat]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> A.flat[5:10] = [4, 3, 2, 1]
>>> print A.formated()
[[1, 2, 3],
[4, 5, 4],
[3, 2, 1]]
a.formated() –> str
Returns a string representing a formated output of Array a
>>> A = Array(range(1, 10), shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
a.get() –> Tuple
Returns a’s internally stored value as a nested tuple, a raw dump of the stored numeric components.
>>> A = Array(range(1, 5), shape=(2, 2))
>>> print A.get()
((1, 2), (3, 4))
a.hstack(b) <==> a.stack(b, axis=-1)
Modifies a by concatenating b at its end, as iterated on last axis. For a 2 dimensional Array/MatrixN, it stacks a and b horizontally.
>>> A = Array([[1, 2], [4, 5]])
>>> print A.formated()
[[1, 2],
[4, 5]]
>>> A.hstack([[3], [6]])
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6]]
a.hstacked(b) <==> a.stacked(b, axis=-1)
Returns the Array obtained by concatenating a and b on last axis. For a 2 dimensional Array/MatrixN, it stacks a and b horizontally.
>>> A = Array([[1, 2], [4, 5]])
>>> print A.formated()
[[1, 2],
[4, 5]]
>>> A = A.hstacked([[3], [6]])
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6]]
a.real() <==> real(a)
Returns the element-wise complex imaginary part of the Array.
>>> A = Array([[complex(1, 2), complex(2, 3)], [complex(4, 5), complex(6, 7)]])
>>> print A.formated()
[[(1+2j), (2+3j)],
[(4+5j), (6+7j)]]
>>> print A.imag().formated()
[[2.0, 3.0],
[5.0, 7.0]]
>>> print imag(A).formated()
[[2.0, 3.0],
[5.0, 7.0]]
>>> A = Array(range(1, 5), shape=(2, 2))
>>> print imag(A).formated()
[[0, 0],
[0, 0]]
a.index(b) –> int or tuple
Returns the index of the first occurrence of b in a.
>>> A = Array(list(range(1, 6))+list(range(4, 0, -1)), shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 4],
[3, 2, 1]]
>>> A.index(5)
(1, 1)
>>> A.index(4)
(1, 0)
>>> A.index([1, 2, 3])
(0,)
>>> A.index([1, 2])
Traceback (most recent call last):
...
ValueError: Array.index(x): x not in Array
a.isEquivalent(b[, tol]) –> bool
Returns True if both arguments have same shape and distance between both Array arguments is inferior or equal to tol.
>>> A = Array([[0.5,0.5,-0.707],[0.707,-0.707,0]])
>>> B = Array([[0.51,0.49,-0.71],[0.71,-0.70,0]])
>>> C = Array([[0.501,0.499,-0.706],[0.706,-0.708,0.01]])
>>> A.dist(B)
0.016340134638368205
>>> A.dist(C)
0.010246950765959599
>>> A.isEquivalent(C, 0.015)
True
>>> A.isEquivalent(B, 0.015)
False
>>> A.isEquivalent(B, 0.020)
True
a.length(axis0, axis1, ...) <==> length(a[, axis=(axis0, axis1, ...)])
Returns length of a, sqrt(a*a) or the square root of the sum of x*x for x in a if a is an iterable of numeric values. If a is an Array and axis are specified will return a list of length(x) for x in a.axisiter(*axis).
>>> A = Array([[0.5,0.5,-0.707],[0.707,-0.707,0.0]])
>>> print A.formated()
[[0.5, 0.5, -0.707],
[0.707, -0.707, 0.0]]
>>> A.length()
1.4140533936170869
>>> A.length(0,1)
1.4140533936170869
>>> A.length(0)
Array([0.99992449715, 0.999848988598])
>>> A.length(1)
Array([0.865938219505, 0.865938219505, 0.707])
a.max([axis0[, axis1[, ...[, key=func]]]]) <==> max(a[, key=func[, axis=(axis0, axis1, ...)]])
Returns the greatest component of a. If axis are specified will return an Array of element-wise max(x) for x in a.axisiter(*axis).
>>> A = Array([[6,3,4],[1,5,0.5]])
>>> print A.formated()
[[6, 3, 4],
[1, 5, 0.5]]
>>> A.max()
6
>>> A.max(0,1)
6
>>> A.max(0)
Array([6, 5, 4])
>>> A.max(1)
Array([6, 5])
a.min([axis0[, axis1[, ...[, key=func]]]]) <==> min(a[, key=func[, axis=(axis0, axis1, ...)]])
Returns the smallest component of a. If axis are specified will return an Array of element-wise min(x) for x in a.axisiter(*axis).
>>> A = Array([[6,3,4],[1,5,0.5]])
>>> print A.formated()
[[6, 3, 4],
[1, 5, 0.5]]
>>> A.min()
0.5
>>> A.min(0, 1)
0.5
>>> A.min(0)
Array([1, 3, 0.5])
>>> A.min(1)
Array([3, 0.5])
a.normal(axis0, axis1, ...) <==> normal(a[, axis=(axis0, axis1, ...)])
Returns a normalized copy of self: self/self.length(axis0, axis1, ...).
>>> A = Array([[0.5,0.5,-0.707],[0.707,-0.707,0.0]])
>>> print A.formated()
[[0.5, 0.5, -0.707],
[0.707, -0.707, 0.0]]
>>> print A.normal().formated()
[[0.353593437318, 0.353593437318, -0.499981120367],
[0.499981120367, -0.499981120367, 0.0]]
>>> print A.normal(0,1).formated()
[[0.353593437318, 0.353593437318, -0.499981120367],
[0.499981120367, -0.499981120367, 0.0]]
>>> print A.normal(0).formated()
[[0.5, 0.5, -0.707],
[0.707, -0.707, 0.0]]
>>> print A.normal(1).formated()
[[0.577408397894, 0.577408397894, -1.0],
[0.816455474623, -0.816455474623, 0.0]]
a.prod([axis0[, axis1[, ...[, start=0]]]]) <=> prod(a, start=start, axis=(axis0, axis1, ...))
Returns the product of all the components of a, an iterable of values that support the mul operator, times start. If axis are specified will return an Array of prod(x) for x in a.axisiter(*axis).
>>> A = Array([[1,2,3],[4,5,6]])
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6]]
>>> A.prod()
720
>>> A.prod(0, 1)
720
>>> A.prod(0)
Array([4, 10, 18])
>>> A.prod(1)
Array([6, 120])
a.ravel() <==> Array(a.flat)
Returns that Array flattened as to a one-dimensional array.
>>> A = Array(range(1, 10), shape=(3, 3))
>>> print repr(A.ravel())
Array([1, 2, 3, 4, 5, 6, 7, 8, 9])
a.real() <==> real(a)
Returns the element-wise complex real part of the Array.
>>> A = Array([[complex(1, 2), complex(2, 3)], [complex(4, 5), complex(6, 7)]])
>>> print A.formated()
[[(1+2j), (2+3j)],
[(4+5j), (6+7j)]]
>>> print A.real().formated()
[[1.0, 2.0],
[4.0, 6.0]]
>>> print real(A).formated()
[[1.0, 2.0],
[4.0, 6.0]]
>>> A = Array(range(1, 5), shape=(2, 2))
>>> print real(A).formated()
[[1, 2],
[3, 4]]
a.reshaped(shape) <==> a.shape = shape
Performs in-place reshape of array a according to the shape argument without changing the Array’s size (total number of components).
Note : as opposed to trim, reshape will reshuffle components and thus not preserve sub-arrays identity.
Examples :
>>> A = Array(range(1, 17), shape=(4, 4))
>>> print A.formated()
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]]
>>> S = A[0]
>>> A.reshape(shape=(2, 2, 4))
>>> print A.formated()
[[[1, 2, 3, 4],
[5, 6, 7, 8]],
<BLANKLINE>
[[9, 10, 11, 12],
[13, 14, 15, 16]]]
>>> S == A[0, 0]
True
>>> S is A[0, 0]
False
a.reshaped(shape) –> Array
Returns a copy the Array as reshaped according to the shape argument, without changing the Array’s size (total number of components)
Examples :
>>> A = Array(range(1, 17), shape=(4, 4))
>>> print A.formated()
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]]
>>> B = A.reshaped(shape=(2, 2, 4))
>>> print B.formated()
[[[1, 2, 3, 4],
[5, 6, 7, 8]],
<BLANKLINE>
[[9, 10, 11, 12],
[13, 14, 15, 16]]]
>>> A[0] == B[0, 0]
True
>>> A[0] is B[0, 0]
False
a.resize([shape[, value]])
Performs in-place resize of array a according to the shape argument. An optional value argument can be passed and will be used to fill the newly created components if the resize results in a size increase, otherwise the Array class default values are used.
Note : as opposed to trim, resize will reshuffle components and thus not preserve sub-arrays identity.
Examples :
>>> A = Array(range(1, 17), shape=(4, 4))
>>> print A.formated()
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]]
>>> S = A[0]
>>> A.resize(shape=(2, 2, 4))
>>> print A.formated()
[[[1, 2, 3, 4],
[5, 6, 7, 8]],
<BLANKLINE>
[[9, 10, 11, 12],
[13, 14, 15, 16]]]
>>> S == A[0, 0]
True
>>> S is A[0, 0]
False
>>> A.resize(shape=(2, 3, 3))
>>> print A.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[10, 11, 12],
[13, 14, 15],
[16, 0, 0]]]
>>> A.resize(shape=(4, 5), value=1)
>>> print A.formated()
[[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 0, 0, 1, 1]]
a.resized([shape [, value]]) –> Array
Returns a copy of the Array resized according to the shape argument. An optional value argument can be passed and will be used to fill the extra components of the new Array if the resize results in a size increase, otherwise the Array class default values are used.
Examples :
>>> A = Array(range(1, 17), shape=(4, 4))
>>> print A.formated()
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]]
>>> B = A.resized(shape=(2, 2, 4))
>>> print B.formated()
[[[1, 2, 3, 4],
[5, 6, 7, 8]],
<BLANKLINE>
[[9, 10, 11, 12],
[13, 14, 15, 16]]]
>>> A[0] == B[0, 0]
True
>>> A[0] is B[0, 0]
False
>>> B = B.resized(shape=(2, 3, 3))
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[10, 11, 12],
[13, 14, 15],
[16, 0, 0]]]
>>> B = B.resized(shape=(4, 5), value=1)
>>> print B.formated()
[[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 0, 0, 1, 1]]
a.shape : tuple
Shape of the Array (number of dimensions and number of components in each dimension).
It can be queried, or set to change the Array’s shape similarly to the reshape method.
>>> A = Array(range(1, 17), shape=(4, 4))
>>> print A.formated()
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]]
>>> S = A[0]
>>> A.shape=(2, 2, 4)
>>> print A.formated()
[[[1, 2, 3, 4],
[5, 6, 7, 8]],
<BLANKLINE>
[[9, 10, 11, 12],
[13, 14, 15, 16]]]
>>> A.shape=(4, 4)
>>> print A.formated()
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]]
Related : see Array.reshape method.
a.sqlength(axis0, axis1, ...) <==> sqlength(a[, axis=(axis0, axis1, ...)])
Returns square length of a, ie a*a or the sum of x*x for x in a if a is an iterable of numeric values. If a is an Array and axis are specified will return a list of sqlength(x) for x in a.axisiter(*axis).
>>> A = Array([[0.5,0.5,-0.707],[0.707,-0.707,0.0]])
>>> print A.formated()
[[0.5, 0.5, -0.707],
[0.707, -0.707, 0.0]]
>>> A.sqlength()
1.999547
>>> A.sqlength(0,1)
1.999547
>>> A.sqlength(0)
Array([0.999849, 0.999698])
>>> A.sqlength(1)
Array([0.749849, 0.749849, 0.499849])
a.stack(b[, axis=0]) –> Array
Modifies a by concatenating b at its end, as iterated on axis.
Note : stacks a copy (deepcopy) of b, not a reference to b. However a is modified in place.
Examples:
>>> A = Array([])
>>> print repr(A)
Array([])
>>> A.stack([1])
>>> print A.formated()
[1]
>>> A.stack([2])
>>> print A.formated()
[1, 2]
>>> A = Array([A])
>>> print A.formated()
[[1, 2]]
>>> A.stack([[4, 5]], axis=0)
>>> print A.formated()
[[1, 2],
[4, 5]]
>>> A.stack([[3], [6]], axis=1)
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6]]
>>> A.stack([[7, 8, 9]])
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> B = Array([A])
>>> B.stack(B)
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]]
>>> B[0] == B[1]
True
>>> B[0] is B[1]
False
>>> A == B[0]
True
>>> A is B[0]
True
>>> B.stack([[[0, 0, 0]], [[0, 0, 0]]], axis=1)
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]],
<BLANKLINE>
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]]]
>>> B.stack([[[0], [0], [0], [1]], [[0], [0], [0], [1]]], axis=2)
>>> print B.formated()
[[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 1]],
<BLANKLINE>
[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 1]]]
a.stacked(b[, axis=0]) –> Array
Returns the Array obtained by concatenating a and b on axis.
Note : returns a deepcopy of a.stack(b[, axis=0]).
Examples:
>>> A = Array([])
>>> print repr(A)
Array([])
>>> A = A.stacked([1])
>>> print A.formated()
[1]
>>> A = A.stacked([2])
>>> print A.formated()
[1, 2]
>>> A = Array([A])
>>> print A.formated()
[[1, 2]]
>>> A = A.stacked([[4, 5]], axis=0)
>>> print A.formated()
[[1, 2],
[4, 5]]
>>> A = A.stacked([[3], [6]], axis=1)
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6]]
>>> A = A.stacked([[7, 8, 9]])
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> B = Array([A])
>>> B = B.stacked(B)
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]]
>>> B[0] == B[1]
True
>>> B[0] is B[1]
False
>>> A == B[0]
True
>>> A is B[0]
False
>>> B = B.stacked([[[0, 0, 0]], [[0, 0, 0]]], axis=1)
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]],
<BLANKLINE>
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]]]
>>> B = B.stacked([[[0], [0], [0], [1]], [[0], [0], [0], [1]]], axis=2)
>>> print B.formated()
[[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 1]],
<BLANKLINE>
[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 1]]]
a.strip(index)
Strip the elements designated by index from a.
Note : as opposed to a.__delete__(index), will collapse dimensions of the Array that end up with only one sub-array.
>>> A = Array(xrange(1, 28), shape=(3, 3, 3))
>>> print A.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]],
<BLANKLINE>
[[19, 20, 21],
[22, 23, 24],
[25, 26, 27]]]
>>> A.shape
(3, 3, 3)
>>> S = A[0]
>>> A.strip(1)
>>> print A.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[19, 20, 21],
[22, 23, 24],
[25, 26, 27]]]
>>> S == A[0]
True
>>> S is A[0]
True
>>> A.strip(-1)
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> S == A
True
>>> S is A
False
>>> S[0] == A[0]
True
>>> S[0] is A[0]
True
>>> A.strip(None, slice(1,3))
>>> print A.formated()
[[1],
[4],
[7]]
>>> A.strip(-1)
>>> print A.formated()
[[1],
[4]]
>>> A.strip(-1)
>>> print A.formated()
[1]
>>> A.strip(-1)
>>> print A.formated()
[]
a.stripped(index) –> Array
Returns a copy (deepcopy) of a with the elements designated by index stripped, as in a.strip(index)
Note : as opposed to a.deleted(index), will collapse dimensions of the Array that end up with only one sub-array.
>>> A = Array(xrange(1, 28), shape=(3, 3, 3))
>>> print A.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]],
<BLANKLINE>
[[19, 20, 21],
[22, 23, 24],
[25, 26, 27]]]
>>> A.shape
(3, 3, 3)
>>> B = A.stripped(1)
>>> print B.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[19, 20, 21],
[22, 23, 24],
[25, 26, 27]]]
>>> B[0] == A[0]
True
>>> B[0] is A[0]
False
>>> B = B.stripped(-1)
>>> print B.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> B == A[0]
True
>>> B is A[0]
False
>>> B[0] == A[0, 0]
True
>>> B[0] is A[0,0]
False
>>> B = B.stripped(None, slice(1,3))
>>> print B.formated()
[[1],
[4],
[7]]
>>> B = B.stripped(-1)
>>> print B.formated()
[[1],
[4]]
>>> B = B.stripped(-1)
>>> print B.formated()
[1]
>>> B = B.stripped(-1)
>>> print B.formated()
[]
a.subiter([dim=None]) –> ArrayIter
Returns an iterator on all sub Arrays for a specific sub Array number of dimension.
a.subiter(0) is equivalent to a.flat: lista sub-arrays of dimension 0, ie components a.subiter() is equivalent to self.subiter(self.ndim-1) and thus to self.__iter__()
Note : ArrayIter iterators support __len__, __getitem__ and __setitem__
>>> A = Array(range(1, 28), shape=(3, 3, 3))
>>> print A.formated()
[[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]],
<BLANKLINE>
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]],
<BLANKLINE>
[[19, 20, 21],
[22, 23, 24],
[25, 26, 27]]]
>>> [a for a in A.subiter(0)]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]
>>> [a for a in A.subiter(1)]
[Array([1, 2, 3]), Array([4, 5, 6]), Array([7, 8, 9]), Array([10, 11, 12]), Array([13, 14, 15]), Array([16, 17, 18]), Array([19, 20, 21]), Array([22, 23, 24]), Array([25, 26, 27])]
>>> [a for a in A.subiter(2)]
[Array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), Array([[10, 11, 12], [13, 14, 15], [16, 17, 18]]), Array([[19, 20, 21], [22, 23, 24], [25, 26, 27]])]
>>> [a for a in A.subiter(3)]
Traceback (most recent call last):
...
ValueError: can only iterate for a sub-dimension inferior to Array's number of dimensions 3
a.sum([axis0[, axis1[, ...[, start=0]]]]) <=> sum(a, start=start, axis=(axis0, axis1, ...))
Returns the sum of all the components of a, plus start. If axis are specified will return an Array of sum(x) for x in a.axisiter(*axis), else will sum on all axis of a.
>>> A = Array([[1,2,3],[4,5,6]])
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6]]
>>> A.sum()
21
>>> A.sum(0, 1)
21
>>> A.sum(0)
Array([5, 7, 9])
>>> A.sum(1)
Array([6, 15])
a.tolist() –> list
Returns that Array converted to a nested list
>>> A = Array(range(1, 10), shape=(3, 3))
>>> print repr(A)
Array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> print repr(list(A))
[Array([1, 2, 3]), Array([4, 5, 6]), Array([7, 8, 9])]
>>> print repr(A.tolist())
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
a.transpose([axis0[, axis1[, ...]]]) –> Array
Returns a reordered / transposed along the specified axes. If no axes are given,or None is passed, switches the complete axes order. For a 2-d array, this is the usual matrix transpose.
>>> A = Array(range(18), shape=(2,3,3))
>>> print A.formated()
[[[0, 1, 2],
[3, 4, 5],
[6, 7, 8]],
<BLANKLINE>
[[9, 10, 11],
[12, 13, 14],
[15, 16, 17]]]
>>> print A.transpose().formated()
[[[0, 9],
[3, 12],
[6, 15]],
<BLANKLINE>
[[1, 10],
[4, 13],
[7, 16]],
<BLANKLINE>
[[2, 11],
[5, 14],
[8, 17]]]
>>> print A.transpose(0,2,1).formated()
[[[0, 3, 6],
[1, 4, 7],
[2, 5, 8]],
<BLANKLINE>
[[9, 12, 15],
[10, 13, 16],
[11, 14, 17]]]
>>> B=MatrixN(range(9), shape=(3, 3))
>>> print B.formated()
[[0, 1, 2],
[3, 4, 5],
[6, 7, 8]]
>>> print B.transpose().formated()
[[0, 3, 6],
[1, 4, 7],
[2, 5, 8]]
a.trim(shape) Performs in-place trimming of array a to given shape. An optional value argument can be passed and will be used to fill the newly created components if the resize results in a size increase.
Note : a is modified in-place
>>> A = Array(range(1, 10), shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> S = A[0]
>>> A.trim(shape=(4, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]]
>>> S == A[0]
True
>>> S is A[0]
True
>>> A.trim(shape=(4, 4))
>>> print A.formated()
[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 0]]
>>> A.trim(shape=(2, 2))
>>> print A.formated()
[[1, 2],
[4, 5]]
a.trimmed([shape [, value]]) –> Array
Returns the Array as “trimmed”, re-sized according to the shape argument. The difference with a resize is that each dimension will be resized individually, thus the shape argument must have the same number of dimensions as the Array a. A value of -1 or None for a shape dimension size will leave it unchanged. An optional value argument can be passed and will be used to fill the newly created components if the trimmed results in a size increase, otherwise the class default values will be used to fill new components
Note : returns a copy (deepcopy) of a.trim([shape [, value]])
>>> A = Array(range(1, 10), shape=(3, 3))
>>> print A.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
>>> B = A.trimmed(shape=(4, 3))
>>> print B.formated()
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[0, 0, 0]]
>>> B[0] == A[0]
True
>>> B[0] is A[0]
False
>>> B = A.trimmed(shape=(4, 4))
>>> print B.formated()
[[1, 2, 3, 0],
[4, 5, 6, 0],
[7, 8, 9, 0],
[0, 0, 0, 0]]
>>> B = A.trimmed(shape=(2, 2))
>>> print B.formated()
[[1, 2],
[4, 5]]
a.vstack(b) <==> a.stack(b, axis=0)
Modifies a by concatenating b at its end, as iterated on first axis. For a 2 dimensional Array/MatrixN, it stacks a and b vertically
>>> A = Array([[1, 2], [3, 4]])
>>> print A.formated()
[[1, 2],
[3, 4]]
>>> A.vstack([[5, 6]])
>>> print A.formated()
[[1, 2],
[3, 4],
[5, 6]]
a.vstacked(b) <==> a.stacked(b, axis=0)
Returns the Array obtained by concatenating a and b on first axis. For a 2 dimensional Array/MatrixN, it stacks a and b vertically.
>>> A = Array([[1, 2], [3, 4]])
>>> print A.formated()
[[1, 2],
[3, 4]]
>>> A = A.vstacked([[5, 6]])
>>> print A.formated()
[[1, 2],
[3, 4],
[5, 6]]