def kpath_from_seekpath(cls, seekpath, point_coords):
        r"""Convert seekpath-formatted kpoints path to sumo-preferred format.

        If 'GAMMA' is used as a label this will be replaced by '\Gamma'.

        Args:
            seekpath (list): A :obj:`list` of 2-tuples containing the labels at
                each side of each segment of the k-point path::

                    [(A, B), (B, C), (C, D), ...]

                where a break in the sequence is indicated by a non-repeating
                label. E.g.::

                    [(A, B), (B, C), (D, E), ...]

                for a break between C and D.
            point_coords (dict): Dict of coordinates corresponding to k-point
                labels::

                    {'GAMMA': [0., 0., 0.], ...}
        Returns:
            dict: The path and k-points as::

                {
                    'path', [[l1, l2, l3], [l4, l5], ...],
                    'kpoints', {l1: [a1, b1, c1], l2: [a2, b2, c2], ...}
                }
        """
        # convert from seekpath format e.g. [(l1, l2), (l2, l3), (l4, l5)]
        # to our preferred representation [[l1, l2, l3], [l4, l5]]
        path = [[seekpath[0][0]]]
        for (k1, k2) in seekpath:
            if path[-1] and path[-1][-1] == k1:
                path[-1].append(k2)
            else:
                path.append([k1, k2])

        # Rebuild kpoints dictionary skipping any positions not on path
        # (chain(*list) flattens nested list; set() removes duplicates.)
        kpoints = {p: point_coords[p] for p in set(chain(*path))}

        # Every path should include Gamma-point. Change the label to \Gamma
        assert 'GAMMA' in kpoints
        kpoints[r'\Gamma'] = kpoints.pop('GAMMA')
        path = [[label.replace('GAMMA', r'\Gamma') for label in subpath]
                for subpath in path]

        return {'kpoints': kpoints, 'path': path}
def kpath_from_seekpath ( cls , seekpath , point_coords ) : path = [ [ seekpath [ 0 ] [ 0 ] ] ] for ( k1 , k2 ) in seekpath : if path [ - 1 ] and path [ - 1 ] [ - 1 ] == k1 : path [ - 1 ] . append ( k2 ) else : path . append ( [ k1 , k2 ] ) kpoints = { p : point_coords [ p ] for p in set ( chain ( * path ) ) } assert 'GAMMA' in kpoints kpoints [ r'\Gamma' ] = kpoints . pop ( 'GAMMA' ) path = [ [ label . replace ( 'GAMMA' , r'\Gamma' ) for label in subpath ] for subpath in path ] return { 'kpoints' : kpoints , 'path' : path }
r"""Convert seekpath-formatted kpoints path to sumo-preferred format.

        If 'GAMMA' is used as a label this will be replaced by '\Gamma'.

        Args:
            seekpath (list): A :obj:`list` of 2-tuples containing the labels at
                each side of each segment of the k-point path::

                    [(A, B), (B, C), (C, D), ...]

                where a break in the sequence is indicated by a non-repeating
                label. E.g.::

                    [(A, B), (B, C), (D, E), ...]

                for a break between C and D.
            point_coords (dict): Dict of coordinates corresponding to k-point
                labels::

                    {'GAMMA': [0., 0., 0.], ...}
        Returns:
            dict: The path and k-points as::

                {
                    'path', [[l1, l2, l3], [l4, l5], ...],
                    'kpoints', {l1: [a1, b1, c1], l2: [a2, b2, c2], ...}
                }