colour.utilities.tstack#

colour.utilities.tstack(a: Union[ArrayLike, NestedSequence[NumberOrArrayLike]], dtype: Optional[Union[Type[DTypeBoolean], Type[DTypeNumber]]] = None) NDArray[source]#

Stack given array of arrays \(a\) along the last axis (tail) to produce a stacked array.

It is used to stack an array of arrays produced by the colour.utilities.tsplit() definition.

Parameters
  • a (Union[ArrayLike, NestedSequence[NumberOrArrayLike]]) – Array of arrays \(a\) to stack along the last axis.

  • dtype (Optional[Union[Type[DTypeBoolean], Type[DTypeNumber]]]) – numpy.dtype to use for initial conversion to numpy.ndarray, default to the numpy.dtype defined by colour.constant.DEFAULT_FLOAT_DTYPE attribute.

Returns

Stacked array.

Return type

numpy.ndarray

Examples

>>> a = 0
>>> tstack([a, a, a])
array([ 0.,  0.,  0.])
>>> a = np.arange(0, 6)
>>> tstack([a, a, a])
array([[ 0.,  0.,  0.],
       [ 1.,  1.,  1.],
       [ 2.,  2.,  2.],
       [ 3.,  3.,  3.],
       [ 4.,  4.,  4.],
       [ 5.,  5.,  5.]])
>>> a = np.reshape(a, (1, 6))
>>> tstack([a, a, a])
array([[[ 0.,  0.,  0.],
        [ 1.,  1.,  1.],
        [ 2.,  2.,  2.],
        [ 3.,  3.,  3.],
        [ 4.,  4.,  4.],
        [ 5.,  5.,  5.]]])
>>> a = np.reshape(a, (1, 1, 6))
>>> tstack([a, a, a])
array([[[[ 0.,  0.,  0.],
         [ 1.,  1.,  1.],
         [ 2.,  2.,  2.],
         [ 3.,  3.,  3.],
         [ 4.,  4.,  4.],
         [ 5.,  5.,  5.]]]])