From fc01da0da011062019e662ee29814365562aed74 Mon Sep 17 00:00:00 2001 From: ElliottKasoar <45317199+ElliottKasoar@users.noreply.github.com> Date: Mon, 2 Sep 2024 16:06:47 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Jacob Wilkins <46597752+oerc0122@users.noreply.github.com> --- janus_core/calculations/md.py | 6 +++--- janus_core/helpers/utils.py | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/janus_core/calculations/md.py b/janus_core/calculations/md.py index 54f0715d..4c294301 100644 --- a/janus_core/calculations/md.py +++ b/janus_core/calculations/md.py @@ -536,7 +536,7 @@ def _prepare_restart(self) -> None: # Use restart_stem.name otherwise T300.0 etc. counts as extension poss_restarts = restart_stem.parent.glob(f"{restart_stem.name}*.extxyz") try: - last_restart = sorted(poss_restarts, key=getmtime)[-1] + last_restart = max(poss_restarts, key=getmtime) # Read in last structure self.struct = input_structs( @@ -556,9 +556,9 @@ def _prepare_restart(self) -> None: try: # Remove restart_stem from filename # Use restart_stem.name otherwise T300.0 etc. counts as extension - self.offset = int("".join(last_stem.split(f"{restart_stem.name}-"))) + self.offset = int(last_stem.split("-")[-1]) - # Check "-"" not inlcuded in offset + # Check "-" not inlcuded in offset assert self.offset > 0 except (ValueError, AssertionError) as e: diff --git a/janus_core/helpers/utils.py b/janus_core/helpers/utils.py index 4d312f2f..6c61dd13 100644 --- a/janus_core/helpers/utils.py +++ b/janus_core/helpers/utils.py @@ -145,10 +145,8 @@ def _build_filename( if filename: built_filename = Path(filename) else: - prefix = ( - str(prefix_override) - if prefix_override is not None - else str(self.file_prefix) + prefix = str( + prefix_override if prefix_override is not None else self.file_prefix ) built_filename = Path("-".join((prefix, *filter(None, additional), suffix)))