diff --git a/docs/user/install.md b/docs/user/install.md index 273f8344b8..d1ec9ecc39 100644 --- a/docs/user/install.md +++ b/docs/user/install.md @@ -8,7 +8,7 @@ This guide will get you up and running in an environment for running high-throug workflows with atomate2. atomate2 is built on the pymatgen, custodian, jobflow, and FireWorks libraries. Briefly: -- [pymatgen] is used create input files and analyze the output of materials science codes. +- [pymatgen] is used to create input files and analyze the output of materials science codes. - [custodian] runs your simulation code (e.g., VASP) and performs error checking/handling and checkpointing. - [jobflow] is used to design computational workflows. @@ -22,9 +22,9 @@ Note that this installation tutorial is VASP-centric since almost all functional currently in atomate2 pertains to VASP. [pymatgen]: http://pymatgen.org -[custodian]: https://materialsproject.github.io/custodian/ -[fireworks]: https://materialsproject.github.io/fireworks/ -[jobflow]: https://materialsproject.github.io/jobflow/ +[custodian]: https://materialsproject.github.io/custodian +[fireworks]: https://materialsproject.github.io/fireworks +[jobflow]: https://materialsproject.github.io/jobflow ### Objectives diff --git a/src/atomate2/common/schemas/cclib.py b/src/atomate2/common/schemas/cclib.py index 8f15a12eae..ba4ceeb41d 100644 --- a/src/atomate2/common/schemas/cclib.py +++ b/src/atomate2/common/schemas/cclib.py @@ -143,10 +143,10 @@ def from_logfile( metadata = jsanitize(cclib_obj.metadata) # monty datetime bug workaround: github.com/materialsvirtuallab/monty/issues/275 - if metadata.get("wall_time", None): - metadata["wall_time"] = [str(m) for m in metadata["wall_time"]] - if metadata.get("cpu_time", None): - metadata["cpu_time"] = [str(m) for m in metadata["cpu_time"]] + if wall_time := metadata.get("wall_time"): + metadata["wall_time"] = [*map(str, wall_time)] + if cpu_time := metadata.get("cpu_time"): + metadata["cpu_time"] = [*map(str, cpu_time)] # Get the final energy to store as its own key/value pair energy = ( @@ -159,8 +159,8 @@ def from_logfile( # the input if it is XYZ-formatted though since the Molecule object # does not support internal coordinates or Gaussian Z-matrix. if ( - cclib_obj.metadata.get("coord_type", None) == "xyz" - and cclib_obj.metadata.get("coords", None) is not None + cclib_obj.metadata.get("coord_type") == "xyz" + and cclib_obj.metadata.get("coords") is not None ): coords_obj = cclib_obj.metadata["coords"] input_species = [Element(row[0]) for row in coords_obj] diff --git a/src/atomate2/common/schemas/defects.py b/src/atomate2/common/schemas/defects.py index 04c89d5058..eea91e13c8 100644 --- a/src/atomate2/common/schemas/defects.py +++ b/src/atomate2/common/schemas/defects.py @@ -275,10 +275,10 @@ def dQ_entries(e1, e2): return get_dQ(e1.structure, e2.structure) # ensure the "dir_name" is provided for each entry - if any(e.data.get("dir_name", None) is None for e in entries1 + entries2): + if any(entry.data.get("dir_name") is None for entry in entries1 + entries2): raise ValueError("[dir_name] must be provided for all entries.") - if any(e.data.get("uuid", None) is None for e in entries1 + entries2): + if any(entry.data.get("uuid") is None for entry in entries1 + entries2): raise ValueError("[uuid] must be provided for all entries.") idx1, ent_r1 = find_entry(entries1, relaxed_uuid1) diff --git a/src/atomate2/cp2k/schemas/calculation.py b/src/atomate2/cp2k/schemas/calculation.py index 9b85e34d90..41c1ec7b70 100644 --- a/src/atomate2/cp2k/schemas/calculation.py +++ b/src/atomate2/cp2k/schemas/calculation.py @@ -111,10 +111,10 @@ def from_cp2k_output(cls, output: Cp2kOutput): """Initialize from Cp2kOutput object.""" return cls( structure=output.initial_structure, - atomic_kind_info=output.data.get("atomic_kind_info", None), + atomic_kind_info=output.data.get("atomic_kind_info"), cp2k_input=output.input.as_dict(), - dft=output.data.get("dft", None), - cp2k_global=output.data.get("global", None), + dft=output.data.get("dft"), + cp2k_global=output.data.get("global"), ) diff --git a/src/atomate2/cp2k/schemas/task.py b/src/atomate2/cp2k/schemas/task.py index 0c1008259f..02d2ef6d19 100644 --- a/src/atomate2/cp2k/schemas/task.py +++ b/src/atomate2/cp2k/schemas/task.py @@ -220,8 +220,8 @@ def from_cp2k_calc_doc(cls, calc_doc: Calculation) -> "OutputSummary": The calculation output summary. """ if calc_doc.output.ionic_steps: - forces = calc_doc.output.ionic_steps[-1].get("forces", None) - stress = calc_doc.output.ionic_steps[-1].get("stress", None) + forces = calc_doc.output.ionic_steps[-1].get("forces") + stress = calc_doc.output.ionic_steps[-1].get("stress") else: forces = None stress = None diff --git a/src/atomate2/utils/file_client.py b/src/atomate2/utils/file_client.py index 00bfde0440..90675b8286 100644 --- a/src/atomate2/utils/file_client.py +++ b/src/atomate2/utils/file_client.py @@ -516,7 +516,7 @@ def auto_fileclient(method: Callable | None = None): def decorator(func): @wraps(func) def gen_fileclient(*args, **kwargs): - file_client = kwargs.get("file_client", None) + file_client = kwargs.get("file_client") if file_client is None: with FileClient() as file_client: kwargs["file_client"] = file_client diff --git a/src/atomate2/vasp/schemas/calc_types/utils.py b/src/atomate2/vasp/schemas/calc_types/utils.py index 5055540c30..879e2d7600 100644 --- a/src/atomate2/vasp/schemas/calc_types/utils.py +++ b/src/atomate2/vasp/schemas/calc_types/utils.py @@ -40,7 +40,7 @@ def _variant_equal(v1, v2) -> bool: for functional_class in ["HF", "VDW", "METAGGA", "GGA"]: for special_type, params in _RUN_TYPE_DATA[functional_class].items(): if all( - _variant_equal(vasp_parameters.get(param, None), value) + _variant_equal(vasp_parameters.get(param), value) for param, value in params.items() ): return RunType(f"{special_type}{is_hubbard}") diff --git a/src/atomate2/vasp/sets/base.py b/src/atomate2/vasp/sets/base.py index 6bc870b7fd..157ce64d82 100644 --- a/src/atomate2/vasp/sets/base.py +++ b/src/atomate2/vasp/sets/base.py @@ -928,7 +928,7 @@ def _get_u_param(lda_param, lda_config, structure): def _get_ediff(param, value, structure, incar_settings): """Get EDIFF.""" - if incar_settings.get("EDIFF", None) is None and param == "EDIFF_PER_ATOM": + if incar_settings.get("EDIFF") is None and param == "EDIFF_PER_ATOM": return float(value) * structure.num_sites return float(incar_settings["EDIFF"]) diff --git a/tests/common/schemas/test_cclib.py b/tests/common/schemas/test_cclib.py index 3a0c30b179..5239de14ea 100644 --- a/tests/common/schemas/test_cclib.py +++ b/tests/common/schemas/test_cclib.py @@ -29,8 +29,8 @@ def test_cclib_taskdoc(test_dir): assert doc["nelectrons"] == 16 assert "schemas" in doc["dir_name"] assert "gau_testopt.log.gz" in doc["logfile"] - assert doc.get("attributes", None) is not None - assert doc.get("metadata", None) is not None + assert doc.get("attributes") is not None + assert doc.get("metadata") is not None assert doc["metadata"]["success"] is True assert doc["attributes"]["molecule_initial"][0].coords == pytest.approx([0, 0, 0]) assert doc["molecule"][0].coords == pytest.approx([0.397382, 0.0, 0.0]) diff --git a/tests/vasp/conftest.py b/tests/vasp/conftest.py index 4d5704c00c..07a48616ea 100644 --- a/tests/vasp/conftest.py +++ b/tests/vasp/conftest.py @@ -197,11 +197,9 @@ def check_kpoints(ref_path: Path): user = Incar.from_file("INCAR") ref = Incar.from_file(ref_path / "inputs" / "INCAR") - if user.get("KSPACING", None) != ref.get("KSPACING", None): - raise ValueError( - "KSPACING is not consistent: " - f"{user.get('KSPACING', None)} != {ref.get('KSPACING', None)}" - ) + user_ksp, ref_ksp = user.get("KSPACING"), ref.get("KSPACING") + if user_ksp != ref_ksp: + raise ValueError(f"KSPACING is not consistent: {user_ksp} != {ref_ksp}") def check_poscar(ref_path: Path):