From 82d7ca21b7724e2533ed8d23f1af989ed1fe619a Mon Sep 17 00:00:00 2001 From: Cen Wang Date: Fri, 21 Nov 2025 22:31:28 -0500 Subject: [PATCH] Temporary fix: restore experiment design types when reloading CSV outputs --- simopt/data_farming_base.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/simopt/data_farming_base.py b/simopt/data_farming_base.py index 2924b7d5..dfc18a71 100644 --- a/simopt/data_farming_base.py +++ b/simopt/data_farming_base.py @@ -7,7 +7,7 @@ from contextlib import suppress from copy import deepcopy from pathlib import Path -from typing import Literal +from typing import Any, Literal import pandas as pd @@ -141,7 +141,7 @@ def simulate(self, num_macroreps: int = 1) -> None: response_key: { factor_key: [] for factor_key in gradients[response_key] } - for response_key in responses + for response_key in gradients } # Append responses and gradients. for key in self.responses: @@ -266,6 +266,20 @@ def __init__( sep="\t", encoding="utf-8", ) + + def fn(x: Any) -> Any: # noqa: ANN401 + import ast + + if isinstance(x, str): + try: + return ast.literal_eval(x) + except Exception: + return x + + return x + + design_table = design_table.applymap(fn) + # If we don't have factor headers, use the column names from the design table. if not factor_headers: factor_headers = design_table.columns.tolist()