Skip to content
Snippets Groups Projects
Commit caf753bd authored by leufen1's avatar leufen1
Browse files

set experiment name now can handle strings and tuples of strings, /close #263

parent 3109116b
Branches
Tags
3 merge requests!253include current develop,!252Resolve "release v1.3.0",!230Resolve "experiment name with mixed sampling"
Pipeline #58296 passed
...@@ -4,13 +4,13 @@ import logging ...@@ -4,13 +4,13 @@ import logging
import os import os
import re import re
import socket import socket
from typing import Tuple from typing import Union
# ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) # ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
ROOT_PATH = os.getcwd() ROOT_PATH = os.getcwd()
def prepare_host(create_new=True, data_path=None, sampling="daily") -> str: def prepare_host(create_new=True, data_path=None) -> str:
""" """
Set up host path. Set up host path.
...@@ -20,7 +20,6 @@ def prepare_host(create_new=True, data_path=None, sampling="daily") -> str: ...@@ -20,7 +20,6 @@ def prepare_host(create_new=True, data_path=None, sampling="daily") -> str:
:param create_new: Create new path if enabled :param create_new: Create new path if enabled
:param data_path: Parse your custom path (and therefore ignore preset paths fitting to known hosts) :param data_path: Parse your custom path (and therefore ignore preset paths fitting to known hosts)
:param sampling: sampling rate to separate data physically by temporal resolution (deprecated)
:return: full path to data :return: full path to data
""" """
...@@ -73,7 +72,7 @@ def set_experiment_path(name: str, path: str = None) -> str: ...@@ -73,7 +72,7 @@ def set_experiment_path(name: str, path: str = None) -> str:
return experiment_path return experiment_path
def set_experiment_name(name: str = None, sampling: str = None) -> str: def set_experiment_name(name: str = None, sampling: Union[str, tuple] = None) -> str:
""" """
Set name of experiment and its path. Set name of experiment and its path.
...@@ -90,6 +89,8 @@ def set_experiment_name(name: str = None, sampling: str = None) -> str: ...@@ -90,6 +89,8 @@ def set_experiment_name(name: str = None, sampling: str = None) -> str:
else: else:
experiment_name = f"{name}_network" experiment_name = f"{name}_network"
if sampling is not None: if sampling is not None:
if not isinstance(sampling, str):
sampling = sampling[-1]
experiment_name += f"_{sampling}" experiment_name += f"_{sampling}"
return experiment_name return experiment_name
......
...@@ -68,6 +68,14 @@ class TestSetExperimentName: ...@@ -68,6 +68,14 @@ class TestSetExperimentName:
exp_name = set_experiment_name(sampling="daily") exp_name = set_experiment_name(sampling="daily")
assert exp_name == "TestExperiment_daily" assert exp_name == "TestExperiment_daily"
def test_set_experiment_name_tuple_sampling(self):
exp_name = set_experiment_name(sampling=("hourly"))
assert exp_name == "TestExperiment_hourly"
exp_name = set_experiment_name(sampling=("hourly", "daily"))
assert exp_name == "TestExperiment_daily"
exp_name = set_experiment_name(sampling=("hourly", "dummy", "daily"))
assert exp_name == "TestExperiment_daily"
def test_set_experiment_path(self): def test_set_experiment_path(self):
exp_path = set_experiment_path("TestExperiment") exp_path = set_experiment_path("TestExperiment")
assert exp_path == os.path.abspath(os.path.join(ROOT_PATH, "TestExperiment")) assert exp_path == os.path.abspath(os.path.join(ROOT_PATH, "TestExperiment"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment