Skip to content

Commit eb37843

Browse files
Merge pull request #3 from felix5572/zezhong-devel
bug fix to help your pull request && modify set subtraction
2 parents 6c83ca8 + ae7ff40 commit eb37843

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

dpdata/system.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ def sort_atom_names(self, type_map=None):
368368
# atom_names must be a subset of type_map
369369
assert (set(self.data['atom_names']).issubset(set(type_map)))
370370
# for the condition that type_map is a proper superset of atom_names
371-
new_atoms = set(type_map) - set(self.data["atom_names"])
371+
# new_atoms = set(type_map) - set(self.data["atom_names"])
372+
new_atoms = [e for e in type_map if e not in self.data["atom_names"]]
372373
if new_atoms:
373374
self.add_atom_names(new_atoms)
374375
# index that will sort an array by type_map
@@ -1455,8 +1456,10 @@ def check_atom_names(self, system):
14551456
"""
14561457
Make atom_names in all systems equal, prevent inconsistent atom_types.
14571458
"""
1458-
new_in_system = set(system["atom_names"]) - set(self.atom_names)
1459-
new_in_self = set(self.atom_names) - set(system["atom_names"])
1459+
# new_in_system = set(system["atom_names"]) - set(self.atom_names)
1460+
# new_in_self = set(self.atom_names) - set(system["atom_names"])
1461+
new_in_system = [e for e in system["atom_names"] if e not in self.atom_names]
1462+
new_in_self = [e for e in self.atom_names if e not in system["atom_names"]]
14601463
if len(new_in_system):
14611464
# A new atom_name appear, add to self.atom_names
14621465
self.atom_names.extend(new_in_system)
@@ -1477,6 +1480,7 @@ def from_quip_gap_xyz_file(self,file_name):
14771480
# print(next(quip_gap_xyz_systems))
14781481
for info_dict in QuipGapxyzSystems(file_name):
14791482
system=LabeledSystem(data=info_dict)
1483+
system.sort_atom_names()
14801484
self.append(system)
14811485

14821486

0 commit comments

Comments
 (0)