From f2be19e734eaee9dc8ccd7f0fc3ebf05ee5fb8e0 Mon Sep 17 00:00:00 2001 From: nilomr Date: Fri, 20 May 2022 15:44:45 +0100 Subject: [PATCH] test relative paths --- tests/scratchpad.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/tests/scratchpad.py b/tests/scratchpad.py index c0af60e..9fc7592 100644 --- a/tests/scratchpad.py +++ b/tests/scratchpad.py @@ -534,7 +534,7 @@ def from_np_array(array_string): np.fromstring(np_str, sep=" ") -#Test moving dataset location +# ──── TEST MOVING DATASET LOCATION ───────────────────────────────────────────── DATASET_ID = "GREAT_TIT" @@ -560,12 +560,31 @@ def from_np_array(array_string): import shutil -move_to = out_dir.parents[1]/f'{out_dir.stem}_MOVED' + +move_to = out_dir.parents[1] / f"{out_dir.stem}_MOVED" shutil.move(out_dir.parent, move_to) -moved_dataset = move_to /f"{DATASET_ID}.db" +moved_dataset = move_to / f"{DATASET_ID}.db" dataset = load_dataset(moved_dataset) dataset.plot(dataset.vocs.index[0]) -dataset.DIRS._deep_update_paths() +testpath = dataset.vocs["spectrogram_loc"][0] + + +def make_relpath(path: Path): + return path.relative_to(path.parents[3]) + + +make_relpath(testpath) +dataset.vocs["spectrogram_loc"] = dataset.vocs["spectrogram_loc"].apply( + lambda x: make_relpath(x) +) + + +p = dataset.vocs["spectrogram_loc"][0].parts[0] + +p.relative_to(p.parents[3]) + + +dataset.DIRS._deep_update_paths(PROJECT, NEW_PROJECT)