Skip to content

Commit

Permalink
fix orbit_groups sortingfix orbit_groups sorting
Browse files Browse the repository at this point in the history
Co-authored-by: Rhys Goodall <rhys.goodall@outlook.com>
  • Loading branch information
janosh and CompRhys authored Feb 2, 2025
1 parent 42d81e3 commit af01dc8
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions matbench_discovery/structure/prototype.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,12 @@ def get_protostructure_label(
spg_num = symmetry_data.number

# Group sites by orbit
orbit_groups: list[list[int]] = []
current_orbit: list[int] = []

for idx, orbit_id in enumerate(symmetry_data.orbits):
if not current_orbit or orbit_id == symmetry_data.orbits[current_orbit[0]]:
current_orbit += [idx]
else:
orbit_groups += [current_orbit]
current_orbit = [idx]
if current_orbit:
orbit_groups += [current_orbit]
orbit_groups: dict[int, list[int]] = {}

for idx, orbit_id in enumerate(moyo_data.orbits):
if orbit_id not in orbit_groups:
orbit_groups[orbit_id] = []
orbit_groups[orbit_id].append(idx)

# Create equivalent_wyckoff_labels from orbit groups
element_dict: dict[str, int] = {}
Expand All @@ -166,7 +161,7 @@ def get_protostructure_label(
str.maketrans("", "", string.digits)
),
)
for orbit in orbit_groups
for orbit in orbit_groups.values()
]
equivalent_wyckoff_labels = sorted(
equivalent_wyckoff_labels, key=lambda x: (x[0], x[2])
Expand Down

0 comments on commit af01dc8

Please sign in to comment.