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

Add an input arg check for Kpoints.automatic_density_by_lengths #3299

Merged
merged 5 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions pymatgen/io/vasp/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,9 @@ def automatic_density_by_lengths(
Returns:
Kpoints
"""
if len(length_densities) != 3:
msg = f"The dimensions of length_densities must be 3, not {len(length_densities)}"
raise ValueError(msg)
comment = f"k-point density of {length_densities}/[a, b, c]"
lattice = structure.lattice
abc = lattice.abc
Expand Down
3 changes: 3 additions & 0 deletions tests/io/vasp/test_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,9 @@ def test_automatic_density_by_lengths(self):

assert kpoints.style == expected_style

with pytest.raises(ValueError, match="The dimensions of length_densities must be 3, not 2"):
Kpoints.automatic_density_by_lengths(structure, [50, 50])

def test_automatic_monkhorst_vs_gamma_style_selection(self):
structs = {key: Structure.from_file(f"{TEST_FILES_DIR}/POSCAR_{key}") for key in ("bcc", "fcc", "hcp")}

Expand Down