Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update VASP input sets for atomate2 compatibility #3835

Merged
merged 22 commits into from
May 23, 2024
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
63728ff
updates for consistency with atomate2 updates
esoteric-ephemera May 13, 2024
a1295b9
Merge remote-tracking branch 'upstream/master'
esoteric-ephemera May 13, 2024
d97ce17
lint
esoteric-ephemera May 13, 2024
04eb1ad
further patch for atomate2 support, make sure tests are respected or …
esoteric-ephemera May 16, 2024
ed0e8ec
linting
esoteric-ephemera May 16, 2024
a31f08b
Merge branch 'materialsproject:master' into master
esoteric-ephemera May 16, 2024
6646b98
merge DictSet into VaspInputSet, deprecate DictSet as an alias of Vas…
janosh May 17, 2024
c50db64
test_dict_set_alias subclass and deprecation message
janosh May 17, 2024
cf8cedc
Change deprecation warning to be on init of DictSet
esoteric-ephemera May 17, 2024
51b25f5
remove deprecated decorator, only works for functions, error msg less…
esoteric-ephemera May 17, 2024
590831f
Merge branch 'materialsproject:master' into master
esoteric-ephemera May 17, 2024
e873ac3
move remaining VaspInputGenerator features to PMG
esoteric-ephemera May 17, 2024
d035806
pre-commit auto-fixes
pre-commit-ci[bot] May 17, 2024
d599611
added tests
esoteric-ephemera May 17, 2024
e1e1a70
add incar, kpoints, poscar, potcar attr to io.vasp.inputs.VaspInput +…
esoteric-ephemera May 17, 2024
ddf74e1
linted
esoteric-ephemera May 17, 2024
c335ce7
Bump rexml from 3.2.5 to 3.2.8 in /docs (#3836)
dependabot[bot] May 17, 2024
9740bba
Bump nokogiri from 1.16.2 to 1.16.5 in /docs (#3828)
dependabot[bot] May 17, 2024
24ad8e9
shift features of VaspInputSet.write_input to VaspInput.write_input
esoteric-ephemera May 20, 2024
c9117f2
pre-commit /linting
esoteric-ephemera May 20, 2024
45c51ec
move file transfer from write_input method of VaspInputSet to VaspInput
esoteric-ephemera May 20, 2024
576db8e
add missing `output_dir` kwarg to vaspinputset.write_input
esoteric-ephemera May 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions tests/io/vasp/test_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ def test_sets_changed(self):
assert hashes[input_set] == known_hashes[input_set], f"{input_set=}\n{msg}"


class TestDictSet(PymatgenTest):
class TestVaspInputSet(PymatgenTest):
@classmethod
def setUpClass(cls):
filepath = f"{VASP_IN_DIR}/POSCAR"
cls.structure = Structure.from_file(filepath)

def test_as_dict(self):
# https://github.com/materialsproject/pymatgen/pull/3031
dict_set = DictSet(self.structure, config_dict={"INCAR": {}}, user_potcar_functional="PBE_54")
dict_set = VaspInputSet(self.structure, config_dict={"INCAR": {}}, user_potcar_functional="PBE_54")
assert {*dict_set.as_dict()} >= {
"@class",
"@module",
Expand Down Expand Up @@ -1580,7 +1580,7 @@ def test_potcar(self):
assert input_set.potcar.functional == "PBE_52"

with pytest.raises(
ValueError, match=r"Invalid self.user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
):
MVLScanRelaxSet(self.struct, user_potcar_functional="PBE")

Expand All @@ -1597,7 +1597,7 @@ def test_potcar(self):
#
# # https://github.com/materialsproject/pymatgen/pull/3022
# # same test also in MITMPRelaxSetTest above (for redundancy,
# # should apply to all classes inheriting from DictSet)
# # should apply to all classes inheriting from VaspInputSet)
# for user_potcar_settings in [{"Fe": "Fe_pv"}, {"W": "W_pv"}, None]:
# for species in [("W", "W"), ("Fe", "W"), ("Fe", "Fe")]:
# struct = Structure(lattice=Lattice.cubic(3), species=species, coords=[[0, 0, 0], [0.5, 0.5, 0.5]])
Expand Down Expand Up @@ -1710,7 +1710,7 @@ def test_potcar(self):
assert input_set.potcar.functional == "PBE_54"

with pytest.raises(
ValueError, match=r"Invalid self.user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
):
MPScanRelaxSet(self.struct, user_potcar_functional="PBE")

Expand Down Expand Up @@ -1880,7 +1880,7 @@ def test_potcar(self):
assert test_potcar_set_1.potcar.functional == "PBE_52"

with pytest.raises(
ValueError, match=r"Invalid self.user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
):
self.set(self.struct, user_potcar_functional="PBE")

Expand Down Expand Up @@ -2094,3 +2094,11 @@ def test_as_from_dict(self):

def test_vasp_input_set_alias():
assert VaspInputSet is VaspInputGenerator


def test_dict_set_alias():
assert isinstance(DictSet(), VaspInputSet)
with pytest.warns(
FutureWarning, match="DictSet is deprecated, and will be removed on 2025-12-31\n; use VaspInputSet"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanielYang59 looks like your recent changes to @deprecated in monty put the new line in front of the semicolon. looks weird to start a line with a semicolon

- 2025-12-31\n;
+ 2025-12-31;\n

Copy link
Contributor

@DanielYang59 DanielYang59 May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this and apologize for this overlook.

https://github.com/materialsvirtuallab/monty/blob/7568d6abcfc8dec14ba3022523656d5f9217835e/monty/dev.py#L94-L109

It looks like the semicolon was original there, and the deprecation message we inserted was too long so a line break was inserted. It would be a bit tricky to properly format this without breaking, I would think about this later

        msg = f"{old.__name__} is deprecated"


        if deadline is not None:
            msg += f", and will be removed on {_deadline:%Y-%m-%d}\n"


        if replacement is not None:
            if isinstance(replacement, property):
                r = replacement.fget
            elif isinstance(replacement, (classmethod, staticmethod)):
                r = replacement.__func__
            else:
                r = replacement
            msg += f"; use {r.__name__} in {r.__module__} instead."


        if message:
            msg += "\n" + message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other change in monty to make if you can add it to the same PR for the message change: this decorator is just for functions. Would be great if there's a way to decorate classes too

):
DictSet()