def make_nd_vec(v, nd=None, t=None, norm=False):
    """ Coerce input to np.array() and validate dimensionality.

    Ensure dimensionality 'n' if passed.
    Cast to type 't' if passed
    Normalize output if norm=True

    .. todo:: Complete make_nd_vec docstring

    """

    # Imports
    import numpy as np
    from scipy import linalg as spla

    # Reduce the input to the extent possible
    out_v = np.array(v, dtype=t).squeeze()

    # Confirm vector form
    if not len(out_v.shape) == 1:
        raise ValueError("'v' is not reducible to a vector.")
    ## end if

    # If indicated, confirm dimensionality
    if nd and not out_v.shape[0] == nd:
        raise ValueError("'v' dimension is " + str(out_v.shape[0]) +
                ", not " + str(nd))
    ## end if

    # Normalize, if indicated
    if norm:
        out_v = out_v / spla.norm(out_v)
    ## end if

    # Return result
    return out_v
def make_nd_vec ( v , nd = None , t = None , norm = False ) : import numpy as np from scipy import linalg as spla out_v = np . array ( v , dtype = t ) . squeeze ( ) if not len ( out_v . shape ) == 1 : raise ValueError ( "'v' is not reducible to a vector." ) if nd and not out_v . shape [ 0 ] == nd : raise ValueError ( "'v' dimension is " + str ( out_v . shape [ 0 ] ) + ", not " + str ( nd ) ) if norm : out_v = out_v / spla . norm ( out_v ) return out_v
Coerce input to np.array() and validate dimensionality.

    Ensure dimensionality 'n' if passed.
    Cast to type 't' if passed
    Normalize output if norm=True

    .. todo:: Complete make_nd_vec docstring