updated directory formatting
This commit is contained in:
@@ -17,6 +17,7 @@ from pathlib import Path
|
|||||||
from typing import Any, Iterable, Iterator, TypeVar, Union
|
from typing import Any, Iterable, Iterator, TypeVar, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from numpy.lib.arraysetops import isin
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from .. import env
|
from .. import env
|
||||||
@@ -185,7 +186,12 @@ def format_variable_list(l: list[tuple[str, Any]]):
|
|||||||
str_list = []
|
str_list = []
|
||||||
for p_name, p_value in l:
|
for p_name, p_value in l:
|
||||||
ps = p_name.replace("/", "").replace(joints[0], "").replace(joints[1], "")
|
ps = p_name.replace("/", "").replace(joints[0], "").replace(joints[1], "")
|
||||||
vs = format_value(p_value).replace("/", "").replace(joints[0], "").replace(joints[1], "")
|
vs = (
|
||||||
|
format_value(p_name, p_value)
|
||||||
|
.replace("/", "")
|
||||||
|
.replace(joints[0], "")
|
||||||
|
.replace(joints[1], "")
|
||||||
|
)
|
||||||
str_list.append(ps + joints[1] + vs)
|
str_list.append(ps + joints[1] + vs)
|
||||||
return joints[0].join(str_list)
|
return joints[0].join(str_list)
|
||||||
|
|
||||||
@@ -194,14 +200,20 @@ def branch_id(branch: tuple[Path, ...]) -> str:
|
|||||||
return "".join("".join(re.sub(r"id\d+\S*num\d+", "", b.name).split()[2:-2]) for b in branch)
|
return "".join("".join(re.sub(r"id\d+\S*num\d+", "", b.name).split()[2:-2]) for b in branch)
|
||||||
|
|
||||||
|
|
||||||
def format_value(value) -> str:
|
def format_value(name: str, value) -> str:
|
||||||
if type(value) == type(False):
|
if value is True or value is False:
|
||||||
return str(value)
|
return str(value)
|
||||||
elif isinstance(value, (float, int)):
|
elif isinstance(value, (float, int)):
|
||||||
|
try:
|
||||||
|
return getattr(BareParams, name).display(value)
|
||||||
|
except AttributeError:
|
||||||
return format(value, ".9g")
|
return format(value, ".9g")
|
||||||
elif isinstance(value, (list, tuple, np.ndarray)):
|
elif isinstance(value, (list, tuple, np.ndarray)):
|
||||||
return "-".join([format_value(v) for v in value])
|
return "-".join([format_value(v) for v in value])
|
||||||
else:
|
elif isinstance(value, str):
|
||||||
|
p = Path(value)
|
||||||
|
if p.exists():
|
||||||
|
return p.stem
|
||||||
return str(value)
|
return str(value)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user