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.ndarrayof 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 = Mis 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)ifKis greater than or equal toM.
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.