def test_simple_ordered_stars():
    basis = np.array([
        [1, 0, 0],
        [2, 2, 0],
        [0, 0, 1]
        ])
    stars = get_ordered_stars(basis, 0.5)
    ref_stars = np.array([
        [0,  0,  0]
        ])
    assert np.abs(ref_stars - stars).sum() < 1e-6
    stars = get_ordered_stars(basis, 1.0)
    ref_stars = np.array([
        [ 0,  0,  0],
        [-1,  0,  0],
        [ 0,  0, -1],
        [ 0,  0,  1],
        [ 1,  0,  0]
        ])
    assert np.abs(ref_stars - stars).sum() < 1e-6
    stars = get_ordered_stars(basis, 2.0)
    ref_stars = np.array([
        [ 0,  0,  0],
        [-1,  0,  0],
        [ 0,  0, -1],
        [ 0,  0,  1],
        [ 1,  0,  0],
        [-1,  0, -1],
        [-1,  0,  1],
        [ 1,  0, -1],
        [ 1,  0,  1],
        [-2,  0,  0],
        [-2,  1,  0],
        [ 0,  0, -2],
        [ 0,  0,  2],
        [ 2, -1,  0],
        [ 2,  0,  0]
        ])
    assert np.abs(ref_stars - stars).sum() < 1e-6
    return
def band_structure(
    direct_space_basis,
    pseudo_fname,
    k_list_fname,
    G_norm_cutoff,
    n_bands,
    ):

    # -- get all necessary objects needed to compute the band structure
    pseudo_Gs, pseudo_coefficients = read_pseudo(pseudo_fname)
    k_vectors = read_kpoints(k_list_fname)
    reciprocal_space_basis = \
        get_reciprocal_space_elementary_vectors(direct_space_basis)
    rs_dot = get_Euclidean_dot_product(reciprocal_space_basis)

    assert pseudo_Gs.shape[0] == pseudo_coefficients.size
    assert k_vectors.shape[1] == 3

    # -- Basis of G vectors used for the matrix diagonalization
    G_basis = get_ordered_stars(reciprocal_space_basis, G_norm_cutoff)

    # -- generate potential matrix, which is k-independent
    potential_matrix = build_potential_matrix(
            G_basis, pseudo_Gs, pseudo_coefficients
            )

    # -- loop over the k points to compute the band energies
    band_energies = []
    for idx, k_vec in enumerate(k_vectors):
        kinetic_matrix = build_kinetic_matrix(k_vec, G_basis, rs_dot)
        hamiltonian = kinetic_matrix + potential_matrix
        eigvals = np.sort(eigvalsh(hamiltonian))[:n_bands]
        band_energies += [eigvals]

    # -- simple check to see if the eigenvalues are real
    band_energies = np.array(band_energies)
    assert np.abs(band_energies.imag).sum() < 1e-3

    return band_energies