Skip to content

SHUFFLE_VECTOR

Download Flojoy Studio to try this app
The SHUFFLE_VECTOR node returns a vector that is randomly shuffled. Params: default : Vector The vector to shuffle. Returns: out : Vector Shuffled input vector
Python Code
from numpy.random import permutation
from flojoy import flojoy, Vector


@flojoy
def SHUFFLE_VECTOR(
    default: Vector,
) -> Vector:
    """The SHUFFLE_VECTOR node returns a vector that is randomly shuffled.

    Parameters
    ----------
    default : Vector
        The vector to shuffle.

    Returns
    -------
    Vector
        Shuffled input vector
    """

    shuffledVector = permutation(default.v)

    return Vector(v=shuffledVector)

Find this Flojoy Block on GitHub

Example App

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 a vector type data using LINSPACE node.

Using SHUFFLE_VECTOR, we randomly shuffle the elements and visualize it using SCATTER node.