Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Wilkins <46597752+oerc0122@users.noreply.github.com>
  • Loading branch information
ElliottKasoar and oerc0122 committed Mar 3, 2025
1 parent cec488e commit 8390d6c
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 119 deletions.
12 changes: 4 additions & 8 deletions janus_core/calculations/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,10 @@ def output_files(self) -> None:
dict[str, PathLike]
Output file labels and paths.
"""
output_files = {}

output_files["log"] = self.log_kwargs["filename"] if self.logger else None
output_files["results"] = (
self.write_kwargs["filename"] if self.write_results else None
)

return output_files
return {
"log": self.log_kwargs["filename"] if self.logger else None,
"results": self.write_kwargs["filename"] if self.write_results else None,
}

def run(self) -> None:
"""Calculate descriptors for structure(s)."""
Expand Down
22 changes: 9 additions & 13 deletions janus_core/calculations/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,15 @@ def output_files(self) -> None:
dict[str, PathLike]
Output file labels and paths.
"""
output_files = {}

output_files["log"] = self.log_kwargs["filename"] if self.logger else None
output_files["generated_structures"] = (
self.write_kwargs["filename"] if self.write_structures else None
)
output_files["plot"] = (
self.plot_kwargs["filename"] if self.plot_to_file else None
)
output_files["fit"] = self.fit_file if self.write_results else None
output_files["raw"] = self.raw_file if self.write_results else None

return output_files
return {
"log": self.log_kwargs["filename"] if self.logger else None,
"generated_structures": self.write_kwargs["filename"]
if self.write_structures
else None,
"plot": self.plot_kwargs["filename"] if self.plot_to_file else None,
"fit": self.fit_file if self.write_results else None,
"raw": self.raw_file if self.write_results else None,
}

def run(self) -> EoSResults:
"""
Expand Down
16 changes: 7 additions & 9 deletions janus_core/calculations/geom_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,13 @@ def output_files(self) -> None:
dict[str, PathLike]
Output file labels and paths.
"""
output_files = {}

output_files["log"] = self.log_kwargs["filename"] if self.logger else None
output_files["optimized_structure"] = (
self.write_kwargs["filename"] if self.write_results else None
)
output_files["trajectory"] = self.traj_kwargs.get("filename")

return output_files
return {
"log": self.log_kwargs["filename"] if self.logger else None,
"optimized_structure": self.write_kwargs["filename"]
if self.write_results
else None,
"trajectory": self.traj_kwargs.get("filename"),
}

def set_optimizer(self) -> None:
"""Set optimizer for geometry optimization."""
Expand Down
50 changes: 23 additions & 27 deletions janus_core/calculations/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,33 +526,29 @@ def output_files(self) -> None:
dict[str, PathLike]
Output file labels and paths.
"""
output_files = {}

output_files["log"] = self.log_kwargs["filename"] if self.logger else None
output_files["stats"] = self.stats_file
output_files["trajectory"] = self.traj_file
output_files["final_structure"] = self.final_file
output_files["restarts"] = self.restart_files if self.restart_files else None
output_files["correlations"] = (
self._correlations_file if self._correlations else None
)
output_files["minimized_initial_structure"] = (
self.minimize_kwargs["write_kwargs"]["filename"]
if self.minimize_kwargs["write_results"]
else None
)
output_files["rdfs"] = (
self._rdf_files
if self.post_process_kwargs.get("rdf_compute", False)
else None
)
output_files["vafs"] = (
self._vaf_files
if self.post_process_kwargs.get("vaf_compute", False)
else None
)

return output_files
return {
"log": self.log_kwargs["filename"] if self.logger else None,
"stats": self.stats_file,
"trajectory": self.traj_file,
"final_structure": self.final_file,
"restarts": self.restart_files if self.restart_files else None,
"correlations": (self._correlations_file if self._correlations else None),
"minimized_initial_structure": (
self.minimize_kwargs["write_kwargs"]["filename"]
if self.minimize_kwargs["write_results"]
else None
),
"rdfs": (
self._rdf_files
if self.post_process_kwargs.get("rdf_compute", False)
else None
),
"vafs": (
self._vaf_files
if self.post_process_kwargs.get("vaf_compute", False)
else None
),
}

def _set_info(self) -> None:
"""Set time in fs, current dynamics step, and density to info."""
Expand Down
28 changes: 12 additions & 16 deletions janus_core/calculations/neb.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,22 +375,18 @@ def output_files(self) -> None:
dict[str, PathLike]
Output file labels and paths.
"""
output_files = {}

output_files["log"] = self.log_kwargs["filename"] if self.logger else None
output_files["results"] = self.results_file if self.write_results else None
output_files["plot"] = self.plot_file if self.plot_band else None
output_files["band"] = (
self.write_kwargs["filename"] if self.write_band else None
)
output_files["minimized_initial_structure"] = (
self.init_struct_min_path if self.minimize else None
)
output_files["minimized_final_structure"] = (
self.final_struct_min_path if self.minimize else None
)

return output_files
return {
"log": self.log_kwargs["filename"] if self.logger else None,
"results": self.results_file if self.write_results else None,
"plot": self.plot_file if self.plot_band else None,
"band": (self.write_kwargs["filename"] if self.write_band else None),
"minimized_initial_structure": (
self.init_struct_min_path if self.minimize else None
),
"minimized_final_structure": (
self.final_struct_min_path if self.minimize else None
),
}

def _set_neb(self) -> None:
"""Set NEB method and optimizer."""
Expand Down
82 changes: 44 additions & 38 deletions janus_core/calculations/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,44 +422,50 @@ def output_files(self) -> None:
dict[str, PathLike]
Output file labels and paths.
"""
output_files = {}

output_files["log"] = self.log_kwargs["filename"] if self.logger else None
output_files["params"] = self.phonopy_file if self.write_results else None
output_files["force_constants"] = (
self.force_consts_file if self.force_consts_to_hdf5 else None
)
output_files["bands"] = (
self.bands_file if self.write_results and "bands" in self.calcs else None
)
output_files["bands_plot"] = self.bands_plot_file if self.plot_to_file else None
output_files["dos"] = (
self.dos_file if self.write_results and "dos" in self.calcs else None
)
output_files["dos_plot"] = (
self.dos_plot_file if self.plot_to_file and "dos" in self.calcs else None
)
output_files["band_dos_plot"] = (
self.bands_dos_plot_file
if self.plot_to_file and "dos" in self.calcs and "bands" in self.calcs
else None
)
output_files["pdos"] = (
self.pdos_file if self.write_results and "pdos" in self.calcs else None
)
output_files["pdos_plot"] = (
self.pdos_plot_file if self.plot_to_file and "pdos" in self.calcs else None
)
output_files["thermal"] = (
self.thermal_file
if self.write_results and "thermal" in self.calcs
else None
)
output_files["minimized_initial_structure"] = (
self.minimize_kwargs["write_kwargs"]["filename"] if self.minimize else None
)

return output_files
return {
"log": self.log_kwargs["filename"] if self.logger else None,
"params": self.phonopy_file if self.write_results else None,
"force_constants": (
self.force_consts_file if self.force_consts_to_hdf5 else None
),
"bands": (
self.bands_file
if self.write_results and "bands" in self.calcs
else None
),
"bands_plot": self.bands_plot_file if self.plot_to_file else None,
"dos": (
self.dos_file if self.write_results and "dos" in self.calcs else None
),
"dos_plot": (
self.dos_plot_file
if self.plot_to_file and "dos" in self.calcs
else None
),
"band_dos_plot": (
self.bands_dos_plot_file
if self.plot_to_file and "dos" in self.calcs and "bands" in self.calcs
else None
),
"pdos": (
self.pdos_file if self.write_results and "pdos" in self.calcs else None
),
"pdos_plot": (
self.pdos_plot_file
if self.plot_to_file and "pdos" in self.calcs
else None
),
"thermal": (
self.thermal_file
if self.write_results and "thermal" in self.calcs
else None
),
"minimized_initial_structure": (
self.minimize_kwargs["write_kwargs"]["filename"]
if self.minimize
else None
),
}

def calc_force_constants(
self, write_force_consts: bool | None = None, **kwargs
Expand Down
12 changes: 4 additions & 8 deletions janus_core/calculations/single_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,10 @@ def output_files(self) -> None:
dict[str, PathLike]
Output file labels and paths.
"""
output_files = {}

output_files["log"] = self.log_kwargs["filename"] if self.logger else None
output_files["results"] = (
self.write_kwargs["filename"] if self.write_results else None
)

return output_files
return {
"log": self.log_kwargs["filename"] if self.logger else None,
"results": (self.write_kwargs["filename"] if self.write_results else None),
}

def _get_potential_energy(self) -> MaybeList[float]:
"""
Expand Down

0 comments on commit 8390d6c

Please sign in to comment.