slmsuite.holography.toolbox.format_vectors#

format_vectors(vectors, expected_dimension=2, handle_dimension='pass')[source]#

Validates that an array of M-dimensional vectors is a numpy.ndarray of shape (M, N). Handles shaping and transposing if, for instance, tuples or row vectors are passed.

Parameters:
  • vectors (array_like) – M-vector or array of M-vectors to process. Desires shape of (M, N).

  • expected_dimension (int) – Dimension of the system, i.e. M.

  • handle_dimension ({"error", "crop", "pass"}) –

    If an array of vectors with larger dimensionality than expected_dimension = M is provided, decides how to handle these:

    • "error" Raises an error if not (M, N).

    • "crop" Crops the higher dimensions and returns (M, N).

    • "pass" Returns (K, N) if K is greater than or equal to M.

    If the array has smaller dimensionality than expected, an error is always raised.

Returns:

vectors – Cleaned column vector(s). Shape of (M, N).

Return type:

numpy.ndarray

Raises:

ValueError – If the vector input was inappropriate.