Skip to content

Commit

Permalink
fix up name scheme for saved sims
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Sep 9, 2024
1 parent 33a3db6 commit 7d52d12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions neurodsp/sim/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ def save_sims(sims, label, file_path=None, replace=False):

assert '_' not in label, 'Cannot have underscores in simulation label.'

save_path_items = ['sim_unknown' if not sims.function else sims.function]
save_path_items = ['sim-unknown' if not sims.function else sims.function.replace('_', '-')]
if isinstance(sims, (VariableSimulations, MultiSimulations)):
if sims.component:
save_path_items.append(sims.component)
save_path_items.append(sims.component.replace('_', '-'))

Check warning on line 131 in neurodsp/sim/io.py

View check run for this annotation

Codecov / codecov/patch

neurodsp/sim/io.py#L131

Added line #L131 was not covered by tests
if sims.update:
save_path_items.append(sims.update)
save_path_items.append(label)
Expand Down Expand Up @@ -178,13 +178,13 @@ def load_sims(load_name, file_path=None):
load_name = matches[0]

splits = load_name.split('_')
function = '_'.join(splits[0:2]) if splits[1] != 'unknown' else None
function = splits[0].replace('-', '_') if 'unknown' not in splits[0] else None

update, component = None, None
if len(splits) > 3:
splits = splits[2:-1]
if len(splits) > 2:
splits = splits[1:-1]
update = splits.pop()
component = '_'.join(splits) if splits else None
component = splits[0].replace('-', '_') if splits else None

load_folder = fpath(file_path, load_name)
load_files = sorted([file for file in os.listdir(load_folder) if file[0] != '.'])
Expand Down
8 changes: 4 additions & 4 deletions neurodsp/tests/sim/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_load_jsonlines():
def test_save_sims_sim(tsims):

label = 'tsims'
folder = '_'.join([tsims.function, label])
folder = '_'.join([tsims.function.replace('_', '-'), label])

save_sims(tsims, label, TEST_FILES_PATH)
assert os.path.exists(TEST_FILES_PATH / folder)
Expand All @@ -69,7 +69,7 @@ def test_load_sims_sim(tsims):
def test_save_sims_vsim(tvsims):

label = 'tvsims'
folder = '_'.join([tvsims.function, tvsims.update, label])
folder = '_'.join([tvsims.function.replace('_', '-'), tvsims.update, label])

save_sims(tvsims, label, TEST_FILES_PATH)
assert os.path.exists(TEST_FILES_PATH / folder)
Expand All @@ -89,8 +89,8 @@ def test_load_sims_vsim(tvsims):
def test_save_sims_msim(tmsims):

label = 'tmsims'
folder = '_'.join([tmsims.function, tmsims.update, label])
sub_folder = '_'.join([tmsims.function, 'set'])
folder = '_'.join([tmsims.function.replace('_', '-'), tmsims.update, label])
sub_folder = '_'.join([tmsims.function.replace('_', '-'), 'set'])

save_sims(tmsims, label, TEST_FILES_PATH)
assert os.path.exists(TEST_FILES_PATH / folder)
Expand Down

0 comments on commit 7d52d12

Please sign in to comment.