Skip to content

Commit 8082052

Browse files
authored
only warn about change of default value of primitive to False if not passed to parse_structures explicitly (#3505)
1 parent 33beea2 commit 8082052

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

pymatgen/core/structure.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,11 +1177,9 @@ def from_magnetic_spacegroup(
11771177
f"{msg.sg_symbol}!"
11781178
)
11791179

1180-
if len(species) != len(coords):
1181-
raise ValueError(f"Supplied species and coords lengths ({len(species)} vs {len(coords)}) are different!")
1182-
1183-
if len(species) != len(magmoms):
1184-
raise ValueError(f"Supplied species and magmom lengths ({len(species)} vs {len(magmoms)}) are different!")
1180+
for name, var in (("coords", coords), ("magmoms", magmoms)):
1181+
if len(var) != len(species):
1182+
raise ValueError(f"Length mismatch: len({name})={len(var)} != {len(species)=}")
11851183

11861184
frac_coords = coords if not coords_are_cartesian else latt.get_fractional_coords(coords)
11871185

pymatgen/io/cif.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ def get_structures(self, *args, **kwargs) -> list[Structure]:
11521152

11531153
def parse_structures(
11541154
self,
1155-
primitive: bool = False,
1155+
primitive: bool | None = None,
11561156
symmetrized: bool = False,
11571157
check_occu: bool = True,
11581158
on_error: Literal["ignore", "warn", "raise"] = "warn",
@@ -1183,12 +1183,14 @@ def parse_structures(
11831183
"""
11841184
if os.getenv("CI") and datetime.now() > datetime(2024, 3, 1): # March 2024 seems long enough # pragma: no cover
11851185
raise RuntimeError("remove the change of default primitive=True to False made on 2023-10-24")
1186-
warnings.warn(
1187-
"The default value of primitive was changed from True to False in "
1188-
"https://github.com/materialsproject/pymatgen/pull/3419. CifParser now returns the cell "
1189-
"in the CIF file as is. If you want the primitive cell, please set primitive=True explicitly.",
1190-
UserWarning,
1191-
)
1186+
if primitive is None:
1187+
primitive = False
1188+
warnings.warn(
1189+
"The default value of primitive was changed from True to False in "
1190+
"https://github.com/materialsproject/pymatgen/pull/3419. CifParser now returns the cell "
1191+
"in the CIF file as is. If you want the primitive cell, please set primitive=True explicitly.",
1192+
UserWarning,
1193+
)
11921194
if not check_occu: # added in https://github.com/materialsproject/pymatgen/pull/2836
11931195
warnings.warn("Structures with unphysical site occupancies are not compatible with many pymatgen features.")
11941196
if primitive and symmetrized:

0 commit comments

Comments
 (0)