def _get_kpoints(kpoint_mesh: Union[float, int, List[int]], structure: Structure, symprec: float = 0.01, return_full_kpoints: bool = False ) -> Tuple[np.ndarray, ...]: """Gets the symmetry inequivalent k-points from a k-point mesh. Follows the same process as SpacegroupAnalyzer.get_ir_reciprocal_mesh but is faster and allows returning of the full k-point mesh and mapping. Args: kpoint_mesh: The k-point mesh as a 1x3 array. E.g.,``[6, 6, 6]``. Alternatively, if a single value is provided this will be treated as a reciprocal density and the k-point mesh dimensions generated automatically. structure: A structure. symprec: Symmetry tolerance used when determining the symmetry inequivalent k-points on which to interpolate. return_full_kpoints: Whether to return the full list of k-points covering the entire Brillouin zone and the indices of inequivalent k-points. Returns: The irreducible k-points and their weights as tuple, formatted as:: (ir_kpoints, weights) If return_full_kpoints, the data will be returned as:: (ir_kpoints, weights, full_kpoints, ir_kpoints_idx, ir_to_full_idx) Where ``ir_kpoints_idx`` is the index of the unique irreducible k-points in ``full_kpoints``. ``ir_to_full_idx`` is a list of indices that can be used to construct the full Brillouin zone from the ir_mesh. Note the ir -> full conversion will only work with calculated scalar properties such as energy (not vector properties such as velocity). """ if isinstance(kpoint_mesh, (int, float)): # TODO: Update this to use reciprocal length as in kgrid kpoint_mesh = Kpoints.automatic_density_by_vol(structure, kpoint_mesh) atoms = AseAtomsAdaptor().get_atoms(structure) if not symprec: symprec = 0.1 mapping, grid = spglib.get_ir_reciprocal_mesh( kpoint_mesh, atoms, symprec=symprec) full_kpoints = grid / kpoint_mesh ir_kpoints_idx, ir_to_full_idx, weights = np.unique( mapping, return_inverse=True, return_counts=True) ir_kpoints = full_kpoints[ir_kpoints_idx] if return_full_kpoints: return ir_kpoints, weights, full_kpoints, ir_kpoints_idx, ir_to_full_idx else: return ir_kpoints, weights