Skip to content

Commit 5cdc9d3

Browse files
committed
revert fc6cfaf and ef0d5a5
1 parent 1975b92 commit 5cdc9d3

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

pymatgen/io/cif.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,6 @@ def get_num_implicit_hydrogens(sym):
895895

896896
coord_to_species = {}
897897
coord_to_magmoms = {}
898-
labels = {}
899898

900899
def get_matching_coord(coord):
901900
keys = list(coord_to_species)
@@ -909,15 +908,15 @@ def get_matching_coord(coord):
909908
return keys[inds[0]]
910909
return False
911910

912-
for i, label in enumerate(data["_atom_site_label"]):
911+
for i in range(len(data["_atom_site_label"])):
913912
try:
914913
# If site type symbol exists, use it. Otherwise, we use the
915914
# label.
916915
symbol = self._parse_symbol(data["_atom_site_type_symbol"][i])
917916
num_h = get_num_implicit_hydrogens(data["_atom_site_type_symbol"][i])
918917
except KeyError:
919-
symbol = self._parse_symbol(label)
920-
num_h = get_num_implicit_hydrogens(label)
918+
symbol = self._parse_symbol(data["_atom_site_label"][i])
919+
num_h = get_num_implicit_hydrogens(data["_atom_site_label"][i])
921920
if not symbol:
922921
continue
923922

@@ -937,7 +936,7 @@ def get_matching_coord(coord):
937936
x = str2float(data["_atom_site_fract_x"][i])
938937
y = str2float(data["_atom_site_fract_y"][i])
939938
z = str2float(data["_atom_site_fract_z"][i])
940-
magmom = magmoms.get(label, np.array([0, 0, 0]))
939+
magmom = magmoms.get(data["_atom_site_label"][i], np.array([0, 0, 0]))
941940

942941
try:
943942
occu = str2float(data["_atom_site_occupancy"][i])
@@ -956,16 +955,13 @@ def get_matching_coord(coord):
956955
"in calculations unless hydrogens added."
957956
)
958957
comp = Composition(comp_d)
959-
960958
if not match:
961959
coord_to_species[coord] = comp
962960
coord_to_magmoms[coord] = magmom
963-
labels[coord] = label
964961
else:
965962
coord_to_species[match] += comp
966963
# disordered magnetic not currently supported
967964
coord_to_magmoms[match] = None
968-
labels[match] = label
969965

970966
sum_occu = [
971967
sum(c.values()) for c in coord_to_species.values() if set(c.elements) != {Element("O"), Element("H")}
@@ -984,7 +980,6 @@ def get_matching_coord(coord):
984980
all_magmoms = []
985981
all_hydrogens = []
986982
equivalent_indices = []
987-
all_labels = []
988983

989984
# check to see if magCIF file is disordered
990985
if self.feature_flags["magcif"]:
@@ -1035,7 +1030,6 @@ def get_matching_coord(coord):
10351030
all_coords.extend(coords)
10361031
all_species.extend(len(coords) * [species])
10371032
all_magmoms.extend(magmoms)
1038-
all_labels.extend(len(coords) * [labels[tmp_coords[0]]])
10391033

10401034
# rescale occupancies if necessary
10411035
for i, species in enumerate(all_species):
@@ -1052,10 +1046,6 @@ def get_matching_coord(coord):
10521046
if self.feature_flags["magcif"]:
10531047
site_properties["magmom"] = all_magmoms
10541048

1055-
if any(all_labels):
1056-
assert len(all_labels) == len(all_species)
1057-
site_properties["labels"] = all_labels
1058-
10591049
if len(site_properties) == 0:
10601050
site_properties = None
10611051

pymatgen/io/tests/test_cif.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -316,19 +316,6 @@ def test_implicit_hydrogen(self):
316316
"in calculations unless hydrogens added." in parser.warnings
317317
)
318318

319-
def test_site_labels(self):
320-
parser = CifParser(f"{self.TEST_FILES_DIR}/garnet.cif")
321-
struct = parser.get_structures()[0]
322-
323-
assert "labels" in struct.site_properties
324-
assert (
325-
len(struct.site_properties["labels"]) == len(struct) == 80
326-
), "Mismatch between number of labels and sites."
327-
assert len(set(struct.site_properties["labels"])) == 4, "Expecting only 4 unique labels"
328-
329-
for label, specie in zip(struct.site_properties["labels"], struct.species):
330-
assert label.startswith(specie.name)
331-
332319
def test_CifParserSpringerPauling(self):
333320
# Below are 10 tests for CIFs from the Springer Materials/Pauling file DBs.
334321

0 commit comments

Comments
 (0)