Download tests/test_core.py from Angshul/Bayesian_LangGraph: direct link, hf CLI and curl.
- Browser
- Download file 898 Bytes
-
https://huggingface.co/Angshul/Bayesian_LangGraph/resolve/main/tests/test_core.py
- Command line
-
hf download hf://Angshul/Bayesian_LangGraph/tests/test_core.py
-
curl -L -o test_core.py https://huggingface.co/Angshul/Bayesian_LangGraph/resolve/main/tests/test_core.py
898 Bytes
| from bayesian_langgraph.core import BayesianIndex, DocumentRecord | |
| from bayesian_langgraph.smc import normalize_logweights | |
| def test_all_negative_infinity_weights_become_uniform(): | |
| p = normalize_logweights([float('-inf'), float('-inf')]) | |
| assert p == [0.5, 0.5] | |
| def test_authoritative_current_document_beats_stale_high_overlap(): | |
| docs = [ | |
| DocumentRecord('stale','The current HR portal is WorkSphere.','Current HR portal','cache',{'reliability_alpha':6,'reliability_beta':6,'authority':0.45,'freshness':0.18}), | |
| DocumentRecord('official','Leave requests and payslips are now handled in PeopleHub.','Migration complete','official',{'reliability_alpha':18,'reliability_beta':2,'authority':0.98,'freshness':1.0}), | |
| ] | |
| hits = BayesianIndex(docs).search('What is the current HR portal for leave requests and payslips?', k=2) | |
| assert hits[0].document.id == 'official' | |