Spaces:
Running
Running
Download backend/tests/test_ascent_kernel.py from Italianhype/Blum: direct link, hf CLI and curl.
- Browser
- Download file 1.89 kB
-
https://huggingface.co/spaces/Italianhype/Blum/resolve/main/backend/tests/test_ascent_kernel.py
- Command line
-
hf download hf://spaces/Italianhype/Blum/backend/tests/test_ascent_kernel.py
-
curl -L -o test_ascent_kernel.py https://huggingface.co/spaces/Italianhype/Blum/resolve/main/backend/tests/test_ascent_kernel.py
1.89 kB
| import math | |
| import pytest | |
| from app.services.ascent.kernel import ArithmeticKernel, generate_candidates | |
| def test_generated_source_changes_forecasts_and_preserves_probability_bounds(): | |
| candidates = generate_candidates(prior=0.5, limit=4) | |
| assert len({source for source in candidates}) == 4 | |
| outputs = [ArithmeticKernel(source).predict(0.9) for source in candidates] | |
| assert outputs == pytest.approx([0.5, 0.6, 0.7, 0.8]) | |
| for source in candidates: | |
| kernel = ArithmeticKernel(source) | |
| assert 0 <= kernel.predict(0) <= kernel.predict(1) <= 1 | |
| def test_candidate_cannot_execute_host_code(source): | |
| with pytest.raises(ValueError): | |
| ArithmeticKernel(source) | |
| def test_invalid_inputs_fail_closed(value): | |
| with pytest.raises(ValueError): | |
| ArithmeticKernel("def calibrate(p):\n return p\n").predict(value) | |
| def test_invalid_outputs_fail_closed(source): | |
| with pytest.raises(ValueError): | |
| ArithmeticKernel(source).predict(0.5) | |