11"""Create test cases for all compatible problem-solver pairs."""
22
3+ import pickle
34import sys
45from pathlib import Path
56
6- import yaml
7+ import zstandard as zstd
78
89# Append the parent directory (simopt package) to the system path
910sys .path .append (str (Path (__file__ ).resolve ().parent .parent ))
@@ -78,16 +79,21 @@ def create_test(problem_name: str, solver_name: str) -> None:
7879 "objective_curves" : myexperiment .objective_curves ,
7980 "progress_curves" : myexperiment .progress_curves ,
8081 "all_est_lhs" : myexperiment .all_est_lhs ,
82+ "all_post_replicates" : myexperiment .all_post_replicates ,
83+ "all_stoch_constraints" : myexperiment .all_stoch_constraints ,
84+ "n_postreps_init_opt" : myexperiment .n_postreps_init_opt ,
85+ "x0_postreps" : myexperiment .x0_postreps ,
86+ "xstar_postreps" : myexperiment .xstar_postreps ,
8187 }
8288
8389 # Define the directory and output file
8490 file_problem_name = "" .join (e for e in problem_name if e .isalnum ())
8591 file_solver_name = "" .join (e for e in solver_name if e .isalnum ())
86- results_filename = f"{ file_problem_name } _{ file_solver_name } .yaml "
92+ results_filename = f"{ file_problem_name } _{ file_solver_name } .pickle.zst "
8793 results_filepath = EXPECTED_RESULTS_DIR / results_filename
8894 # Write the results to the file
89- with Path .open (results_filepath , "w " ) as f :
90- yaml .dump (results_dict , f )
95+ with zstd .open (results_filepath , "wb " ) as f :
96+ pickle .dump (results_dict , f )
9197
9298
9399def main () -> None :
@@ -103,7 +109,7 @@ def main() -> None:
103109 # Create the test directory if it doesn't exist
104110 # Create the expected directory if it doesn't exist
105111 Path .mkdir (EXPECTED_RESULTS_DIR , parents = True , exist_ok = True )
106- existing_results = [path .name for path in EXPECTED_RESULTS_DIR .glob ("*.yaml " )]
112+ existing_results = [path .name for path in EXPECTED_RESULTS_DIR .glob ("*.pickle.zst " )]
107113
108114 # Don't generate any tests for pairs that already have tests generated
109115 for pair in compatible_pairs :
@@ -112,7 +118,7 @@ def main() -> None:
112118 # Generate the expected filenames
113119 file_problem_name = "" .join (e for e in problem_name if e .isalnum ())
114120 file_solver_name = "" .join (e for e in solver_name if e .isalnum ())
115- results_filename = f"{ file_problem_name } _{ file_solver_name } .yaml "
121+ results_filename = f"{ file_problem_name } _{ file_solver_name } .pickle.zst "
116122 # If file exists, skip it
117123 if results_filename in existing_results :
118124 print (f"Test for { pair } already exists" )
0 commit comments