Skip to content

INTERLEAVE_VECTOR

The INTERLEAVE_VECTOR node combine multiple vectors into a single vector type by interleaving their elements. Params: default : Vector The input vector Returns: out : Vector Interleaved vector
Python Code
from numpy import stack
from flojoy import flojoy, Vector


@flojoy
def INTERLEAVE_VECTOR(
    default: Vector,
    a: list[Vector],
) -> Vector:
    """The INTERLEAVE_VECTOR node combine multiple vectors into a single vector type by interleaving their elements.

    Parameters
    ----------
    default : Vector
        The input vector

    Returns
    -------
    Vector
        Interleaved vector
    """
    interleavedVectors = [default.v]

    for i in range(len(a)):
        interleavedVectors = interleavedVectors + [a[i].v]

    interleavedVector = stack(interleavedVectors)
    interleavedVector = interleavedVector.T.flatten()

    return Vector(v=interleavedVector)

Find this Flojoy Block on GitHub

Example

Having problems with this example app? Join our Discord community and we will help you out!
React Flow mini map

In this example, we generate four different vector type data with the same size using LINSPACE node.

Using INTERLEAVE_VECTOR node, we merge these data into a single vector and visualize it using SCATTER node.