Skip to content

Commit 7dd059c

Browse files
Zhuoyingpre-commit-ci[bot]janosh
authored
Add tests for the New Vasp input sets (#3576)
* polish test_set.py * minor fix * add MITMDSet test * ruff format check * add ISC001 into ignore (ruff fix) * ruff fix in tests * pre-commit auto-fixes * formatting * add tests for MPAbsorptionSet * check inherit_incar * increase test coverage * regex small fix * formatting * Delete .coverage file * revert pyproject.toml * fix pin monty<=2024.1.23 (was wrong date) * tweak invalid mode error messages, update tests --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Janosh Riebesell <[email protected]>
1 parent a389f4b commit 7dd059c

File tree

3 files changed

+180
-34
lines changed

3 files changed

+180
-34
lines changed

pymatgen/io/vasp/sets.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def __post_init__(self):
394394
)
395395

396396
if self.vdw:
397-
vdw_par = loadfn(str(MODULE_DIR / "vdW_parameters.yaml"))
397+
vdw_par = loadfn(MODULE_DIR / "vdW_parameters.yaml")
398398
try:
399399
self._config_dict["INCAR"].update(vdw_par[self.vdw])
400400
except KeyError:
@@ -1684,12 +1684,15 @@ def __post_init__(self):
16841684
"""Perform inputset validation."""
16851685
super().__post_init__()
16861686

1687-
self.mode = self.mode.lower()
1687+
mode = self.mode = self.mode.lower()
16881688

1689-
if self.mode not in ["line", "uniform", "boltztrap"]:
1690-
raise ValueError("Supported modes for NonSCF runs are 'line', 'uniform' and 'boltztrap!")
1689+
valid_modes = ("line", "uniform", "boltztrap")
1690+
if mode not in valid_modes:
1691+
raise ValueError(
1692+
f"Invalid {mode=}. Supported modes for NonSCF runs are {', '.join(map(repr, valid_modes))}"
1693+
)
16911694

1692-
if (self.mode.lower() != "uniform" or self.nedos < 2000) and self.optics:
1695+
if (mode != "uniform" or self.nedos < 2000) and self.optics:
16931696
warnings.warn("It is recommended to use Uniform mode with a high NEDOS for optics calculations.")
16941697

16951698
if self.standardize:
@@ -2018,10 +2021,10 @@ class MVLGWSet(DictSet):
20182021
def __post_init__(self):
20192022
"""Validate input settings."""
20202023
super().__post_init__()
2021-
self.mode = self.mode.upper()
2024+
self.mode = mode = self.mode.upper()
20222025

2023-
if self.mode not in MVLGWSet.SUPPORTED_MODES:
2024-
raise ValueError(f"{self.mode} not one of the support modes : {MVLGWSet.SUPPORTED_MODES}")
2026+
if mode not in MVLGWSet.SUPPORTED_MODES:
2027+
raise ValueError(f"Invalid {mode=}, supported modes are {', '.join(map(repr, MVLGWSet.SUPPORTED_MODES))}")
20252028

20262029
@property
20272030
def kpoints_updates(self) -> dict:
@@ -2259,7 +2262,7 @@ def __init__(self, structures, unset_encut=False, **kwargs):
22592262
**kwargs: Other kwargs supported by DictSet.
22602263
"""
22612264
if len(structures) < 3:
2262-
raise ValueError("You need at least 3 structures for an NEB.")
2265+
raise ValueError(f"You need at least 3 structures for an NEB, got {len(structures)}")
22632266
kwargs["sort_structure"] = False
22642267
super().__init__(structures[0], MITRelaxSet.CONFIG, **kwargs)
22652268
self.structures = self._process_structures(structures)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
python_requires=">=3.9",
3030
install_requires=[
3131
"matplotlib>=1.5",
32-
"monty<=2024.1.26", # https://github.com/materialsvirtuallab/monty/issues/610
32+
"monty<=2024.1.23", # https://github.com/materialsvirtuallab/monty/issues/610
3333
"networkx>=2.2",
3434
"numpy>=1.25.0",
3535
"palettable>=3.1.1",

0 commit comments

Comments
 (0)