INTERLEAVE_VECTOR
The INTERLEAVE_VECTOR node combine multiple vectors into a single vector type by interleaving their elements.Params:default : VectorThe input vectorReturns:out : VectorInterleaved 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)
Example
Having problem with this example app? Join our Discord community and we will help you out!
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.