Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dev = [
"pytest>=9.0.1",
"ruff>=0.14.2",
"ty>=0.0.1a26",
"zstandard>=0.25.0",
]
docs = ["sphinx>=8.2.3", "sphinx-autoapi>=3.6.1", "sphinx-rtd-theme>=3.0.2"]
notebooks = ["ipykernel>=7.1.0"]
Expand Down
13 changes: 7 additions & 6 deletions scripts/generate_experiment_results.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Create test cases for all compatible problem-solver pairs."""

import pickle
import sys
from pathlib import Path

import yaml
import zstandard as zstd

# Append the parent directory (simopt package) to the system path
sys.path.append(str(Path(__file__).resolve().parent.parent))
Expand Down Expand Up @@ -83,11 +84,11 @@ def create_test(problem_name: str, solver_name: str) -> None:
# Define the directory and output file
file_problem_name = "".join(e for e in problem_name if e.isalnum())
file_solver_name = "".join(e for e in solver_name if e.isalnum())
results_filename = f"{file_problem_name}_{file_solver_name}.yaml"
results_filename = f"{file_problem_name}_{file_solver_name}.pickle.zst"
results_filepath = EXPECTED_RESULTS_DIR / results_filename
# Write the results to the file
with Path.open(results_filepath, "w") as f:
yaml.dump(results_dict, f)
with zstd.open(results_filepath, "wb") as f:
pickle.dump(results_dict, f)


def main() -> None:
Expand All @@ -103,7 +104,7 @@ def main() -> None:
# Create the test directory if it doesn't exist
# Create the expected directory if it doesn't exist
Path.mkdir(EXPECTED_RESULTS_DIR, parents=True, exist_ok=True)
existing_results = [path.name for path in EXPECTED_RESULTS_DIR.glob("*.yaml")]
existing_results = [path.name for path in EXPECTED_RESULTS_DIR.glob("*.pickle.zst")]

# Don't generate any tests for pairs that already have tests generated
for pair in compatible_pairs:
Expand All @@ -112,7 +113,7 @@ def main() -> None:
# Generate the expected filenames
file_problem_name = "".join(e for e in problem_name if e.isalnum())
file_solver_name = "".join(e for e in solver_name if e.isalnum())
results_filename = f"{file_problem_name}_{file_solver_name}.yaml"
results_filename = f"{file_problem_name}_{file_solver_name}.pickle.zst"
# If file exists, skip it
if results_filename in existing_results:
print(f"Test for {pair} already exists")
Expand Down
Binary file not shown.
Loading