Skip to content

Commit 6c83ca8

Browse files
committed
sort atom according to the type_map of user input instead of alphabetic order
1 parent 13bd118 commit 6c83ca8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

dpdata/system.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ def formula(self):
414414
"""
415415
Return the formula of this system, like C3H5O2
416416
"""
417-
return ''.join(["{}{}".format(symbol,numb) for symbol,numb in sorted(
418-
zip(self.data['atom_names'], self.data['atom_numbs']))])
417+
return ''.join(["{}{}".format(symbol,numb) for symbol,numb in
418+
zip(self.data['atom_names'], self.data['atom_numbs'])])
419419

420420

421421
def extend(self, systems):
@@ -1460,18 +1460,17 @@ def check_atom_names(self, system):
14601460
if len(new_in_system):
14611461
# A new atom_name appear, add to self.atom_names
14621462
self.atom_names.extend(new_in_system)
1463-
self.atom_names.sort()
14641463
# Add this atom_name to each system, and change their names
14651464
new_systems = {}
14661465
for each_system in self.systems.values():
14671466
each_system.add_atom_names(new_in_system)
1468-
each_system.sort_atom_names()
1467+
each_system.sort_atom_names(type_map=self.atom_names)
14691468
new_systems[each_system.formula] = each_system
14701469
self.systems = new_systems
14711470
if len(new_in_self):
14721471
# Previous atom_name not in this system
14731472
system.add_atom_names(new_in_self)
1474-
system.sort_atom_names()
1473+
system.sort_atom_names(type_map=self.atom_names)
14751474

14761475
def from_quip_gap_xyz_file(self,file_name):
14771476
# quip_gap_xyz_systems = QuipGapxyzSystems(file_name)

0 commit comments

Comments
 (0)