diff --git a/neurodsp/sim/io.py b/neurodsp/sim/io.py index 3c4a03db..bc7f7be3 100644 --- a/neurodsp/sim/io.py +++ b/neurodsp/sim/io.py @@ -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('_', '-')) if sims.update: save_path_items.append(sims.update) save_path_items.append(label) @@ -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] != '.']) diff --git a/neurodsp/tests/sim/test_io.py b/neurodsp/tests/sim/test_io.py index 1dd0db29..2d2f4b66 100644 --- a/neurodsp/tests/sim/test_io.py +++ b/neurodsp/tests/sim/test_io.py @@ -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) @@ -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) @@ -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)