Skip to content

Commit

Permalink
only warn about change of default value of primitive to False if not …
Browse files Browse the repository at this point in the history
…passed to parse_structures explicitly (#3505)
  • Loading branch information
janosh authored Dec 7, 2023
1 parent 33beea2 commit 8082052
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 3 additions & 5 deletions pymatgen/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,11 +1177,9 @@ def from_magnetic_spacegroup(
f"{msg.sg_symbol}!"
)

if len(species) != len(coords):
raise ValueError(f"Supplied species and coords lengths ({len(species)} vs {len(coords)}) are different!")

if len(species) != len(magmoms):
raise ValueError(f"Supplied species and magmom lengths ({len(species)} vs {len(magmoms)}) are different!")
for name, var in (("coords", coords), ("magmoms", magmoms)):
if len(var) != len(species):
raise ValueError(f"Length mismatch: len({name})={len(var)} != {len(species)=}")

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

Expand Down
16 changes: 9 additions & 7 deletions pymatgen/io/cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ def get_structures(self, *args, **kwargs) -> list[Structure]:

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

0 comments on commit 8082052

Please sign in to comment.