Datasets:
Formats:
csv
Languages:
English
Size:
1K - 10K
Tags:
arxiv-artifact
reproducibility
research-artifact
computer-science
computer-logic
formal-methods
License:
| import csv | |
| import json | |
| from pcmt.pipeline import RunConfig, run_pipeline | |
| from pcmt.robustness import make_robustness_figures, run_robustness_atlas | |
| def test_robustness_atlas_writes_aggregate_certificate_stability_tables(tmp_path): | |
| run_dir = tmp_path / "run" | |
| output = tmp_path / "robustness" | |
| run_pipeline(RunConfig(output=run_dir, fixture_root=tmp_path / "fixtures", clips=2, edits=["none", "audio_shift"], use_gpu="cpu")) | |
| metrics = run_robustness_atlas(run_dir, output, thresholds=5, radii=[0, 1, 2], use_gpu="cpu", sample_limit=4) | |
| assert metrics["phase_rows"] == 5 * 3 * 5 | |
| assert metrics["max_defect_bound_violation"] == 0.0 | |
| expected = [ | |
| "stability_cube_summary.csv", | |
| "stability_phase_diagram_values.csv", | |
| "threshold_radius_counterexample_preservation.csv", | |
| "certificate_margin_table.csv", | |
| "sample_unstable_certificates.jsonl", | |
| "robustness_metrics.json", | |
| ] | |
| for name in expected: | |
| assert (output / name).exists() | |
| with (output / "stability_cube_summary.csv").open("r", encoding="utf-8", newline="") as handle: | |
| rows = list(csv.DictReader(handle)) | |
| assert any(row["formula_id"] == "ALL" for row in rows) | |
| assert max(float(row["max_defect_bound_violation"]) for row in rows) == 0.0 | |
| saved = json.loads((output / "robustness_metrics.json").read_text()) | |
| assert saved["groups"] == 4 | |
| def test_robustness_figure_renders_phase_diagram(tmp_path): | |
| run_dir = tmp_path / "run" | |
| atlas = tmp_path / "robustness" | |
| figures = tmp_path / "figures" | |
| run_pipeline(RunConfig(output=run_dir, fixture_root=tmp_path / "fixtures", clips=1, edits=["none"], use_gpu="cpu")) | |
| run_robustness_atlas(run_dir, atlas, thresholds=4, radii=[0, 1], use_gpu="cpu") | |
| paths = make_robustness_figures(atlas, figures) | |
| assert (figures / "certificate_stability_phase_diagram.png").exists() | |
| assert (figures / "certificate_stability_phase_diagram.pdf").exists() | |
| assert paths["phase_png"].endswith(".png") | |