File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77from contextlib import suppress
88from copy import deepcopy
99from pathlib import Path
10- from typing import Literal
10+ from typing import Any , Literal
1111
1212import pandas as pd
1313
@@ -141,7 +141,7 @@ def simulate(self, num_macroreps: int = 1) -> None:
141141 response_key : {
142142 factor_key : [] for factor_key in gradients [response_key ]
143143 }
144- for response_key in responses
144+ for response_key in gradients
145145 }
146146 # Append responses and gradients.
147147 for key in self .responses :
@@ -266,6 +266,20 @@ def __init__(
266266 sep = "\t " ,
267267 encoding = "utf-8" ,
268268 )
269+
270+ def fn (x : Any ) -> Any : # noqa: ANN401
271+ import ast
272+
273+ if isinstance (x , str ):
274+ try :
275+ return ast .literal_eval (x )
276+ except Exception :
277+ return x
278+
279+ return x
280+
281+ design_table = design_table .applymap (fn )
282+
269283 # If we don't have factor headers, use the column names from the design table.
270284 if not factor_headers :
271285 factor_headers = design_table .columns .tolist ()
You can’t perform that action at this time.
0 commit comments