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 ))
@@ -83,11 +84,11 @@ def create_test(problem_name: str, solver_name: str) -> None:
8384 # Define the directory and output file
8485 file_problem_name = "" .join (e for e in problem_name if e .isalnum ())
8586 file_solver_name = "" .join (e for e in solver_name if e .isalnum ())
86- results_filename = f"{ file_problem_name } _{ file_solver_name } .yaml "
87+ results_filename = f"{ file_problem_name } _{ file_solver_name } .pickle.zst "
8788 results_filepath = EXPECTED_RESULTS_DIR / results_filename
8889 # Write the results to the file
89- with Path .open (results_filepath , "w " ) as f :
90- yaml .dump (results_dict , f )
90+ with zstd .open (results_filepath , "wb " ) as f :
91+ pickle .dump (results_dict , f )
9192
9293
9394def main () -> None :
@@ -103,7 +104,7 @@ def main() -> None:
103104 # Create the test directory if it doesn't exist
104105 # Create the expected directory if it doesn't exist
105106 Path .mkdir (EXPECTED_RESULTS_DIR , parents = True , exist_ok = True )
106- existing_results = [path .name for path in EXPECTED_RESULTS_DIR .glob ("*.yaml " )]
107+ existing_results = [path .name for path in EXPECTED_RESULTS_DIR .glob ("*.pickle.zst " )]
107108
108109 # Don't generate any tests for pairs that already have tests generated
109110 for pair in compatible_pairs :
@@ -112,7 +113,7 @@ def main() -> None:
112113 # Generate the expected filenames
113114 file_problem_name = "" .join (e for e in problem_name if e .isalnum ())
114115 file_solver_name = "" .join (e for e in solver_name if e .isalnum ())
115- results_filename = f"{ file_problem_name } _{ file_solver_name } .yaml "
116+ results_filename = f"{ file_problem_name } _{ file_solver_name } .pickle.zst "
116117 # If file exists, skip it
117118 if results_filename in existing_results :
118119 print (f"Test for { pair } already exists" )
0 commit comments