Skip to content

Commit 0b038fe

Browse files
docstr
1 parent 8a2f937 commit 0b038fe

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

pymatgen/io/validation/common.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ class LightVasprun(BaseModel):
9696

9797
@classmethod
9898
def from_vasprun(cls, vasprun: Vasprun) -> Self:
99+
"""
100+
Create a LightVasprun from a pymatgen Vasprun.
101+
102+
Parameters
103+
-----------
104+
vasprun : pymatgen Vasprun
105+
106+
Returns
107+
-----------
108+
LightVasprun
109+
"""
99110
return cls(
100111
**{k: getattr(vasprun, k) for k in cls.model_fields if k != "bandgap"},
101112
bandgap=vasprun.get_band_structure(efermi="smart").get_band_gap()["energy"],
@@ -129,6 +140,17 @@ def deserialize_objects(self) -> dict[str, Any]:
129140

130141
@classmethod
131142
def from_vasp_input_set(cls, vis: VaspInputSet) -> Self:
143+
"""
144+
Create a VaspInputSafe from a pymatgen VaspInputSet.
145+
146+
Parameters
147+
-----------
148+
vasprun : pymatgen VaspInputSet
149+
150+
Returns
151+
-----------
152+
VaspInputSafe
153+
"""
132154
new_vis = cls(
133155
**{
134156
k: getattr(vis, k)
@@ -160,6 +182,7 @@ class VaspFiles(BaseModel):
160182

161183
@property
162184
def actual_kpoints(self) -> Kpoints | None:
185+
"""The actual KPOINTS / IBZKPT used in the calculation, if applicable."""
163186
if self.user_input.kpoints:
164187
return self.user_input.kpoints
165188
elif self.vasprun:

pymatgen/io/validation/validation.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@
2020

2121

2222
class VaspValidator(BaseModel):
23+
"""Validate a VASP calculation."""
2324

2425
reasons: list[str] = Field([], description="List of deprecation tags detailing why this task isn't valid")
2526
warnings: list[str] = Field([], description="List of warnings about this calculation")
2627
vasp_files: VaspFiles = Field(description="The VASP I/O.")
2728

2829
@property
2930
def is_valid(self) -> bool:
31+
"""Determine if the calculation is valid."""
3032
return len(self.reasons) == 0
3133

3234
@property
3335
def has_warnings(self) -> bool:
36+
"""Determine if any warnings were incurred."""
3437
return len(self.warnings) > 0
3538

3639
@classmethod
@@ -41,6 +44,29 @@ def from_vasp_input(
4144
fast: bool = False,
4245
check_potcar: bool = True,
4346
):
47+
"""
48+
Validate a VASP calculation from VASP files or their object representation.
49+
50+
Parameters
51+
-----------
52+
vasp_file_paths : dict of str to os.PathLike, optional
53+
If specified, a dict of the form:
54+
{
55+
"incar": < path to INCAR>,
56+
"poscar": < path to POSCAR>,
57+
...
58+
}
59+
where keys are taken by `VaspFiles.from_paths`.
60+
vasp_files : VaspFiles, optional
61+
This takes higher precendence than `vasp_file_paths`, and
62+
allows the user to specify VASP input/output from a VaspFiles
63+
object.
64+
fast : bool (default = False)
65+
Whether to stop validation at the first failure (True)
66+
or to list all reasons why a calculation failed (False)
67+
check_potcar : bool (default = True)
68+
Whether to check the POTCAR for validity.
69+
"""
4470

4571
if vasp_files:
4672
vf: VaspFiles = vasp_files

pymatgen/io/validation/vasp_defaults.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ class VaspParam(BaseModel):
8484

8585
@staticmethod
8686
def listify(val: Any) -> list[Any]:
87+
"""Return scalars as list of single scalar.
88+
89+
Parameters
90+
-----------
91+
val (Any) : scalar or vector-like
92+
93+
Returns
94+
-----------
95+
list containing val if val was a scalar,
96+
otherwise the list version of val.
97+
"""
8798
if hasattr(val, "__len__"):
8899
if isinstance(val, str):
89100
return [val]

0 commit comments

Comments
 (0)