Skip to content

Commit ac51e26

Browse files
committed
DictSet drop deprecated kwarg potcar_functional: str = None, use user_potcar_functional: str = None instead
1 parent 3c91e69 commit ac51e26

File tree

2 files changed

+15
-37
lines changed

2 files changed

+15
-37
lines changed

pymatgen/io/vasp/sets.py

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from glob import glob
4848
from itertools import chain
4949
from pathlib import Path
50+
from typing import Any, Literal
5051
from zipfile import ZipFile
5152

5253
import numpy as np
@@ -250,24 +251,25 @@ class DictSet(VaspInputSet):
250251

251252
def __init__(
252253
self,
253-
structure,
254-
config_dict,
254+
structure: Structure,
255+
config_dict: dict[str, Any],
255256
files_to_transfer=None,
256257
user_incar_settings=None,
257258
user_kpoints_settings=None,
258259
user_potcar_settings=None,
259-
constrain_total_magmom=False,
260-
sort_structure=True,
261-
potcar_functional=None,
262-
user_potcar_functional=None,
263-
force_gamma=False,
260+
constrain_total_magmom: bool = False,
261+
sort_structure: bool = True,
262+
user_potcar_functional: Literal[
263+
"PBE", "PBE_52", "PBE_54", "LDA", "LDA_52", "LDA_54", "PW91", "LDA_US", "PW91_US"
264+
] = None,
265+
force_gamma: bool = False,
264266
reduce_structure=None,
265267
vdw=None,
266-
use_structure_charge=False,
267-
standardize=False,
268+
use_structure_charge: bool = False,
269+
standardize: bool = False,
268270
sym_prec=0.1,
269-
international_monoclinic=True,
270-
validate_magmom=True,
271+
international_monoclinic: bool = True,
272+
validate_magmom: bool = True,
271273
):
272274
"""
273275
Args:
@@ -385,22 +387,8 @@ def __init__(
385387
raise KeyError(
386388
f"Invalid or unsupported van-der-Waals functional. Supported functionals are {', '.join(vdw_par)}."
387389
)
388-
# read the POTCAR_FUNCTIONAL from the .yaml
389-
self.potcar_functional = self._config_dict.get("POTCAR_FUNCTIONAL", "PBE")
390-
391-
if potcar_functional is not None and user_potcar_functional is not None:
392-
raise ValueError(
393-
"Received both 'potcar_functional' and 'user_potcar_functional arguments. "
394-
"'potcar_functional is deprecated."
395-
)
396-
if potcar_functional:
397-
warnings.warn(
398-
"'potcar_functional' argument is deprecated. Use 'user_potcar_functional' instead.",
399-
FutureWarning,
400-
)
401-
self.potcar_functional = potcar_functional
402-
elif user_potcar_functional:
403-
self.potcar_functional = user_potcar_functional
390+
# 'or' case reads the POTCAR_FUNCTIONAL from the .yaml
391+
self.potcar_functional = user_potcar_functional or self._config_dict.get("POTCAR_FUNCTIONAL", "PBE")
404392

405393
# warn if a user is overriding POTCAR_FUNCTIONAL
406394
if self.potcar_functional != self._config_dict.get("POTCAR_FUNCTIONAL"):

pymatgen/io/vasp/tests/test_sets.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -662,11 +662,6 @@ def test_write_input_zipped(self):
662662

663663
os.remove("MPStaticSet.zip")
664664

665-
def test_conflicting_arguments(self):
666-
si = self.get_structure("Si")
667-
with pytest.raises(ValueError, match="deprecated"):
668-
MPStaticSet(si, potcar_functional="PBE", user_potcar_functional="PBE")
669-
670665
def test_grid_size_from_struct(self):
671666
# TODO grab a bunch_of_calculations store as a list of tuples
672667
# (structure, ngx, ..., ngxf, ...) where all the grid size values are generated by vasp
@@ -1544,11 +1539,6 @@ def test_override_from_prev_calc(self):
15441539
assert lepsilon_vis.incar.get("NSW") is None
15451540
assert lepsilon_vis.incar.get("NPAR") is None
15461541

1547-
def test_conflicting_arguments(self):
1548-
si = self.get_structure("Si")
1549-
with pytest.raises(ValueError, match="deprecated"):
1550-
MPScanStaticSet(si, potcar_functional="PBE", user_potcar_functional="PBE")
1551-
15521542
def tearDown(self):
15531543
shutil.rmtree(self.tmp)
15541544
warnings.simplefilter("default")

0 commit comments

Comments
 (0)