Skip to content

Commit b84e83c

Browse files
linting
1 parent bfaaca7 commit b84e83c

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

pymatgen/io/validation/validation.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,13 @@ def from_dict(
267267
task_type=cls_kwargs["task_type"],
268268
defaults=_vasp_defaults,
269269
fft_grid_tolerance=fft_grid_tolerance,
270-
fast = fast,
270+
fast=fast,
271271
).check()
272272

273273
return cls(valid=len(cls_kwargs["reasons"]) == 0, **cls_kwargs)
274274

275275
@classmethod
276-
def from_directory(
277-
cls,
278-
dir_name: Path | str,
279-
**kwargs
280-
) -> ValidationDoc:
276+
def from_directory(cls, dir_name: Path | str, **kwargs) -> ValidationDoc:
281277
"""
282278
Determines if a calculation is valid based on expected input parameters from a pymatgen inputset
283279
@@ -301,7 +297,7 @@ def from_directory(
301297
)
302298

303299
return cls.from_task_doc(task_doc=task_doc, **kwargs)
304-
300+
305301
except Exception as e:
306302
if "no vasp files found" in str(e).lower():
307303
raise Exception(f"NO CALCULATION FOUND --> {dir_name} is not a VASP calculation directory.")

tests/conftest.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
21
from emmet.core.tasks import TaskDoc
32
from pathlib import Path
43
import pytest
54

65
_test_dir = Path(__file__).parent.joinpath("test_files").resolve()
76

7+
88
@pytest.fixture(scope="session")
99
def test_dir():
1010
return _test_dir
@@ -252,7 +252,5 @@ def get_test_object(object_name):
252252
"""Get the schema test data object from the class name."""
253253
return objects[object_name]
254254

255-
test_data_task_docs = {
256-
k : TaskDoc.from_directory(dir_name = _test_dir / "vasp" / v.folder)
257-
for k, v in objects.items()
258-
}
255+
256+
test_data_task_docs = {k: TaskDoc.from_directory(dir_name=_test_dir / "vasp" / v.folder) for k, v in objects.items()}

tests/test_validation.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ def run_check(
2020
should_the_check_pass: bool,
2121
vasprun_parameters_to_change: dict = {}, # for changing the parameters read from vasprun.xml
2222
incar_settings_to_change: dict = {}, # for directly changing the INCAR file,
23-
validation_doc_kwargs : dict = {}, # any kwargs to pass to the ValidationDoc class
23+
validation_doc_kwargs: dict = {}, # any kwargs to pass to the ValidationDoc class
2424
):
2525
for key, value in vasprun_parameters_to_change.items():
2626
task_doc.input.parameters[key] = value
2727

2828
for key, value in incar_settings_to_change.items():
2929
task_doc.calcs_reversed[0].input.incar[key] = value
3030

31-
validation_doc = ValidationDoc.from_task_doc(task_doc,**validation_doc_kwargs)
31+
validation_doc = ValidationDoc.from_task_doc(task_doc, **validation_doc_kwargs)
3232
has_specified_error = any([error_message_to_search_for in reason for reason in validation_doc.reasons])
3333

3434
assert (not has_specified_error) if should_the_check_pass else has_specified_error
@@ -564,11 +564,12 @@ def test_task_document(test_dir):
564564

565565
expected_reasons = ["KPOINTS", "ENCUT", "ENAUG"]
566566
for expected_reason in expected_reasons:
567-
assert any(expected_reason in reason for reason in valid_docs["non-compliant"].reasons)
567+
assert any(expected_reason in reason for reason in valid_docs["non-compliant"].reasons)
568+
568569

569570
def test_fast_mode():
570571
task_doc = test_data_task_docs["SiStatic"]
571-
valid_doc = ValidationDoc.from_task_doc(task_doc,check_potcar=False)
572+
valid_doc = ValidationDoc.from_task_doc(task_doc, check_potcar=False)
572573

573574
# Without POTCAR check, this doc is valid
574575
assert valid_doc.valid
@@ -587,34 +588,37 @@ def test_fast_mode():
587588
# should only get version error in reasons
588589
task_doc.calcs_reversed[0].vasp_version = "4.0.0"
589590
task_doc.input.parameters["NBANDS"] = -5
590-
bad_incar_updates = {"METAGGA": "R2SCAN", "GGA": "PE",}
591+
bad_incar_updates = {
592+
"METAGGA": "R2SCAN",
593+
"GGA": "PE",
594+
}
591595
task_doc.calcs_reversed[0].input.incar.update(bad_incar_updates)
592-
593-
_update_kpoints_for_test(task_doc, {"kpoints": [[1,1,2]]})
594-
595-
valid_doc = ValidationDoc.from_task_doc(task_doc, check_potcar = True, fast = True)
596+
597+
_update_kpoints_for_test(task_doc, {"kpoints": [[1, 1, 2]]})
598+
599+
valid_doc = ValidationDoc.from_task_doc(task_doc, check_potcar=True, fast=True)
596600
assert len(valid_doc.reasons) == 1
597601
assert "VASP VERSION" in valid_doc.reasons[0]
598602

599603
# Now correct version, should just get METAGGA / GGA bug
600604
task_doc.calcs_reversed[0].vasp_version = "6.3.2"
601-
valid_doc = ValidationDoc.from_task_doc(task_doc, check_potcar = True, fast = True)
605+
valid_doc = ValidationDoc.from_task_doc(task_doc, check_potcar=True, fast=True)
602606
assert len(valid_doc.reasons) == 1
603607
assert "KNOWN BUG" in valid_doc.reasons[0]
604608

605609
# Now remove GGA tag, get k-point density error
606610
task_doc.calcs_reversed[0].input.incar.pop("GGA")
607-
valid_doc = ValidationDoc.from_task_doc(task_doc, check_potcar = True, fast = True)
611+
valid_doc = ValidationDoc.from_task_doc(task_doc, check_potcar=True, fast=True)
608612
assert len(valid_doc.reasons) == 1
609613
assert "INPUT SETTINGS --> KPOINTS or KSPACING:" in valid_doc.reasons[0]
610614

611615
# Now restore k-points and check POTCAR --> get error
612616
_update_kpoints_for_test(task_doc, og_kpoints)
613-
valid_doc = ValidationDoc.from_task_doc(task_doc, check_potcar = True, fast = True)
617+
valid_doc = ValidationDoc.from_task_doc(task_doc, check_potcar=True, fast=True)
614618
assert len(valid_doc.reasons) == 1
615619
assert "PSEUDOPOTENTIALS" in valid_doc.reasons[0]
616620

617621
# Without POTCAR check, should get INCAR check error for NGX
618-
valid_doc = ValidationDoc.from_task_doc(task_doc, check_potcar = False, fast = True)
622+
valid_doc = ValidationDoc.from_task_doc(task_doc, check_potcar=False, fast=True)
619623
assert len(valid_doc.reasons) == 1
620624
assert "NBANDS" in valid_doc.reasons[0]

0 commit comments

Comments
 (0)