From 02dc4af2f2a20dff7953f11649535514e854a357 Mon Sep 17 00:00:00 2001 From: jasondet Date: Fri, 3 Nov 2023 06:22:51 +0100 Subject: [PATCH 1/4] do subs before os vars --- src/lgdo/lgdo_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lgdo/lgdo_utils.py b/src/lgdo/lgdo_utils.py index ec47c6b0..c6f9bfa0 100644 --- a/src/lgdo/lgdo_utils.py +++ b/src/lgdo/lgdo_utils.py @@ -143,7 +143,8 @@ def expand_vars(expr: str, substitute: dict[str, str] = None) -> str: # expand env variables first # then try using provided mapping - return string.Template(os.path.expandvars(expr)).safe_substitute(substitute) + expr = string.Template(expr).safe_substitute(substitute) + return os.path.expandvars(expr) def expand_path( From 29c1813cd03265c3203389da67bd311207d49d1b Mon Sep 17 00:00:00 2001 From: jasondet Date: Fri, 3 Nov 2023 07:30:02 +0100 Subject: [PATCH 2/4] don't convert to list --- src/lgdo/types/table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lgdo/types/table.py b/src/lgdo/types/table.py index c321bfcc..46429140 100644 --- a/src/lgdo/types/table.py +++ b/src/lgdo/types/table.py @@ -225,7 +225,7 @@ def get_dataframe( if not hasattr(column, "nda"): raise ValueError(f"column {col} does not have an nda") else: - df[prefix + str(col)] = column.nda.tolist() + df[prefix + str(col)] = column.nda #.tolist() return df From c0eb837c6abe05785cbe7f75dcd5d8b87880f61e Mon Sep 17 00:00:00 2001 From: jasondet Date: Fri, 3 Nov 2023 07:48:18 +0100 Subject: [PATCH 3/4] but non 1D things have to stay as lists --- src/lgdo/types/table.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lgdo/types/table.py b/src/lgdo/types/table.py index 46429140..b727a5be 100644 --- a/src/lgdo/types/table.py +++ b/src/lgdo/types/table.py @@ -225,7 +225,10 @@ def get_dataframe( if not hasattr(column, "nda"): raise ValueError(f"column {col} does not have an nda") else: - df[prefix + str(col)] = column.nda #.tolist() + if len(column.nda.shape) == 1: + df[prefix + str(col)] = column.nda + else: + df[prefix + str(col)] = column.nda.tolist() return df From e53fc4107859c9a2efff1081227f9aa3488db6f1 Mon Sep 17 00:00:00 2001 From: jasondet Date: Fri, 3 Nov 2023 07:48:55 +0100 Subject: [PATCH 4/4] scalars can be str. --- src/lgdo/types/scalar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lgdo/types/scalar.py b/src/lgdo/types/scalar.py index 86630899..6b793137 100644 --- a/src/lgdo/types/scalar.py +++ b/src/lgdo/types/scalar.py @@ -18,7 +18,7 @@ class Scalar(LGDO): # TODO: do scalars need proper numpy dtypes? - def __init__(self, value: int | float, attrs: dict[str, Any] = None) -> None: + def __init__(self, value: int | float | str, attrs: dict[str, Any] = None) -> None: """ Parameters ----------