Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions simopt/data_farming_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down