Download tests/test_parse_vote.py from 42e/mathcompose: direct link, hf CLI and curl.
- Browser
- Download file 824 Bytes
-
https://huggingface.co/42e/mathcompose/resolve/169e9ea4520e41619e00a971821792d243fe81ec/tests/test_parse_vote.py
- Command line
-
hf download hf://42e/mathcompose@169e9ea4520e41619e00a971821792d243fe81ec/tests/test_parse_vote.py
-
curl -L -o test_parse_vote.py https://huggingface.co/42e/mathcompose/resolve/169e9ea4520e41619e00a971821792d243fe81ec/tests/test_parse_vote.py
824 Bytes
| """Maj@k index voting + solution-level p_correct.""" | |
| from mathcompose.eval.parse import first_error_index, majority_index, p_correct_from_samples, PARSE_FAIL | |
| def test_first_error_index(): | |
| assert first_error_index(r"\boxed{4}") == 4 | |
| assert first_error_index(r"\boxed{-1}") == -1 | |
| assert first_error_index("junk") == PARSE_FAIL | |
| def test_majority_index_drops_failures_and_breaks_ties_low(): | |
| assert majority_index([r"\boxed{2}", r"\boxed{2}", r"\boxed{3}", "junk"]) == 2 | |
| # tie between 2 and 3 -> earliest (2) | |
| assert majority_index([r"\boxed{2}", r"\boxed{3}"]) == 2 | |
| assert majority_index(["junk", "more junk"]) == PARSE_FAIL | |
| def test_p_correct(): | |
| assert p_correct_from_samples([r"\boxed{-1}", r"\boxed{-1}", r"\boxed{4}", r"\boxed{-1}"]) == 0.75 | |
| assert p_correct_from_samples([]) == 0.0 | |