diff --git a/pymatgen/core/structure.py b/pymatgen/core/structure.py index 555a4a3fcfe..e227d1dc478 100644 --- a/pymatgen/core/structure.py +++ b/pymatgen/core/structure.py @@ -1097,7 +1097,7 @@ def from_spacegroup( for k, v in props.items(): all_site_properties[k].extend([v[idx]] * len(cc)) - return cls(latt, all_sp, all_coords, site_properties=all_site_properties) + return cls(latt, all_sp, all_coords, site_properties=all_site_properties, labels=all_labels) @classmethod def from_magnetic_spacegroup( diff --git a/tests/core/test_structure.py b/tests/core/test_structure.py index d8dcd28b8c7..5271fa9adb8 100644 --- a/tests/core/test_structure.py +++ b/tests/core/test_structure.py @@ -1307,8 +1307,10 @@ def test_from_spacegroup(self): ["Li", "O"], [[0.25, 0.25, 0.25], [0, 0, 0]], site_properties={"charge": [1, -2]}, + labels=["A", "B"], ) assert sum(s2.site_properties["charge"]) == 0 + assert s2.labels == ["A", "A", "A", "A", "A", "A", "A", "A", "B", "B", "B", "B"] struct = Structure.from_spacegroup("Pm-3m", Lattice.cubic(3), ["Cs", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]]) assert struct.formula == "Cs1 Cl1"