Skip to content

Commit

Permalink
Fix label propagation in Symmetry.from_spacegroup (#3527)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefsmeets authored Dec 19, 2023
1 parent 36e289c commit 1dd74a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pymatgen/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions tests/core/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1dd74a8

Please sign in to comment.