(matrix)
return matrix
check if the given matrix is legal.
check if the given matrix is legal.
check if the given matrix is legal .
def check_matrix(matrix):
    """check if the given matrix is legal."""
    matrix = check_array(matrix, accept_sparse='csr', ensure_2d=False, order='C')
    if matrix.ndim != 2:
        if matrix.ndim == 1 and len(matrix) == 1:
            matrix = matrix.reshape(1, -1)
        else:
            raise TypeError("Matrix should be a 2D array with [n_samples, n_features] or [n_samples, n_classes].")
    return matrix
def check_matrix ( matrix ) : matrix = check_array ( matrix , accept_sparse = 'csr' , ensure_2d = False , order = 'C' ) if matrix . ndim != 2 : if matrix . ndim == 1 and len ( matrix ) == 1 : matrix = matrix . reshape ( 1 , - 1 ) else : raise TypeError ( "Matrix should be a 2D array with [n_samples, n_features] or [n_samples, n_classes]." ) return matrix