Download tests/test_pairwise_unary_stack.py from Dhruv1000/tracegrpo: direct link, hf CLI and curl.
- Browser
- Download file 901 Bytes
-
https://huggingface.co/Dhruv1000/tracegrpo/resolve/main/tests/test_pairwise_unary_stack.py
- Command line
-
hf download hf://Dhruv1000/tracegrpo/tests/test_pairwise_unary_stack.py
-
curl -L -o test_pairwise_unary_stack.py https://huggingface.co/Dhruv1000/tracegrpo/resolve/main/tests/test_pairwise_unary_stack.py
901 Bytes
| import numpy as np | |
| from scripts.run_pairwise_unary_stack import score_metrics | |
| def test_stacked_metrics_compute_per_class_accuracy_and_pair_pass(): | |
| y = np.array([0, 1, 0, 1], dtype=np.int8) | |
| pred = np.array([0, 1, 1, 0], dtype=np.int8) | |
| result = score_metrics(y, pred, pair_count=2) | |
| assert result["accuracy"] == 0.5 | |
| assert result["safe_accuracy"] == 0.5 | |
| assert result["vulnerable_accuracy"] == 0.5 | |
| assert result["pair_pass_at_1"] == 0.5 | |
| assert result["pair_pass_wilson_95"] is not None | |
| def test_stacked_metrics_track_single_class_collapse(): | |
| y = np.array([0, 1, 0, 1], dtype=np.int8) | |
| pred = np.zeros(4, dtype=np.int8) | |
| result = score_metrics(y, pred, pair_count=2) | |
| assert result["safe_accuracy"] == 1.0 | |
| assert result["vulnerable_accuracy"] == 0.0 | |
| assert result["predicted_vulnerable_fraction"] == 0.0 | |
| assert result["pair_pass_at_1"] == 0.0 | |