def is_vector ( inp ) : inp = np . asarray ( inp ) nr_dim = np . ndim ( inp ) if nr_dim == 1 : return True elif ( nr_dim == 2 ) and ( 1 in inp . shape ) : return True else : return False
check if data is sequence of vectors python
Returns true if the input can be interpreted as a true vector
def is_vector(inp):
    """ Returns true if the input can be interpreted as a 'true' vector

    Note
    ----
    Does only check dimensions, not if type is numeric

    Parameters
    ----------
    inp : numpy.ndarray or something that can be converted into ndarray

    Returns
    -------
    Boolean
        True for vectors: ndim = 1 or ndim = 2 and shape of one axis = 1
        False for all other arrays
    """
    inp = np.asarray(inp)
    nr_dim = np.ndim(inp)
    if nr_dim == 1:
        return True
    elif (nr_dim == 2) and (1 in inp.shape):
        return True
    else:
        return False