pymatgen
pymatgen copied to clipboard
`.as_dict()` method on `VaspInput` causes an `AttributeError`
Python version
3.11
Pymatgen version
2024.5.1
Operating system version
No response
Current behavior
When calling VaspInputSet.get_input_set(), the returned VaspInput has a broken .as_dict() method. That is reported below. The returned VaspInput is already a dict, so that's what should be presented. What is somewhat confusing though is that the method should really be called .get_vasp_input() since it returns a VaspInput and not a VaspInputSet.
from pymatgen.core import Structure
from pymatgen.io.vasp.sets import MPStaticSet
s = Structure(
lattice=[[0, 2.13, 2.13], [2.13, 0, 2.13], [2.13, 2.13, 0]],
species=["Ni", "O"],
coords=[[0, 0, 0], [0.5, 0.5, 0.5]],
)
vasp_input = MPStaticSet().get_input_set(structure=s, potcar_spec=True)
print(vasp_input.as_dict())
Traceback:
File ~/software/miniconda/envs/quacc/lib/python3.11/site-packages/pymatgen/io/vasp/inputs.py:2758, in VaspInput.as_dict(self)
2756 def as_dict(self) -> dict:
2757 """MSONable dict."""
-> 2758 dct = {key: val.as_dict() for key, val in self.items()}
2759 dct["@module"] = type(self).__module__
2760 dct["@class"] = type(self).__name__
File ~/software/miniconda/envs/quacc/lib/python3.11/site-packages/pymatgen/io/vasp/inputs.py:2758, in <dictcomp>(.0)
2756 def as_dict(self) -> dict:
2757 """MSONable dict."""
-> 2758 dct = {key: val.as_dict() for key, val in self.items()}
2759 dct["@module"] = type(self).__module__
2760 dct["@class"] = type(self).__name__
AttributeError: 'list' object has no attribute 'as_dict'
Expected Behavior
The .as_dict() method should return a dictionary.