Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
Change-Id: Ic44a24779e836f1fd96862b5b7a9cd8604e5e59f
  • Loading branch information
Jaquier Aurélien Tristan committed May 30, 2024
1 parent 539419c commit c780aa1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions bluepyemodel/tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def checkpoint_path_exists(checkpoint_path):


def get_checkpoint_path(metadata, seed=None):
"""Get checkpoint path. Use legacy format if any is found, if not use latest format."""
"""Get checkpoint path. Use legacy format if any is found, else use latest format."""
base_path = f"./checkpoints/{metadata.emodel}/{metadata.iteration}/"
# legacy case 1 (2023.05.11 - 2023.10.19)
filename = metadata.as_string(
Expand Down Expand Up @@ -110,15 +110,15 @@ def yesno(question):


def get_seed_from_checkpoint_path(path):
""""""
"""Get seed from checkpoint path name. default seed is 0 if not found."""

if path.endswith(".tmp"):
path = path.replace(".tmp", "")

filename = Path(path).stem.split("__")

search_str = "seed="
seed = next((e.replace(search_str, "") for e in filename if search_str in e), None)
seed = next((e.replace(search_str, "") for e in filename if search_str in e), 0)

return int(seed)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_optimisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

def checkpoint_check(dir, fname, metadata, inner_dir):
f = dir / fname
f.write_text("")
f.touch()
assert str(get_checkpoint_path(metadata, seed=0)) == "/".join((".", inner_dir, fname))
f.unlink()

Expand Down

0 comments on commit c780aa1

Please sign in to comment.