def check_sym(ikjl, nmo, sym):
    """Check permutational symmetry of integral

    Parameters
    ----------
    ikjl : tuple of ints
        Orbital indices of ERI.
    nmo : int
        Number of orbitals
    sym : int
        Desired permutational symmetry to check.

    Returns
    -------
    sym_allowed : bool
        True if integral is unique from set of equivalent.
    """
    if sym == 1:
        return True
    else:
        i, k, j, l = ikjl
        if sym == 4:
            kilj = (k,i,l,j)
            jlik = (j,l,i,k)
            ljki = (l,j,k,i)
            if (ikjl > jlik) or (ikjl > kilj) or (ikjl > ljki):
                return False
            else:
                return True
        else:
            ik = i + k*nmo
            jl = j + l*nmo
            return (i >= k and j >= l) and ik >= jl