Download tests/test_calibrate_code_margin.py from Dhruv1000/tracegrpo: direct link, hf CLI and curl.
- Browser
- Download file 613 Bytes
-
https://huggingface.co/Dhruv1000/tracegrpo/resolve/main/tests/test_calibrate_code_margin.py
- Command line
-
hf download hf://Dhruv1000/tracegrpo/tests/test_calibrate_code_margin.py
-
curl -L -o test_calibrate_code_margin.py https://huggingface.co/Dhruv1000/tracegrpo/resolve/main/tests/test_calibrate_code_margin.py
613 Bytes
| import pytest | |
| from scripts.calibrate_code_margin import select_balanced_accuracy_threshold | |
| def test_threshold_uses_balanced_accuracy_and_separates_both_classes(): | |
| result = select_balanced_accuracy_threshold([0, 0, 1, 1], [-2.0, -1.0, 1.0, 2.0]) | |
| assert result["threshold"] == 0.0 | |
| assert result["balanced_accuracy"] == 1.0 | |
| assert result["safe_accuracy"] == 1.0 | |
| assert result["vulnerable_accuracy"] == 1.0 | |
| def test_threshold_rejects_single_class_calibration_data(): | |
| with pytest.raises(ValueError, match="SAFE/VULNERABLE"): | |
| select_balanced_accuracy_threshold([0, 0], [-1.0, 1.0]) | |