Datasets:
Download tests/test_relations.py from ulamai/UnsolvedMedical: direct link, hf CLI and curl.
- Browser
- Download file 949 Bytes
-
https://huggingface.co/datasets/ulamai/UnsolvedMedical/resolve/main/tests/test_relations.py
- Command line
-
hf download hf://datasets/ulamai/UnsolvedMedical/tests/test_relations.py
-
curl -L -o test_relations.py https://huggingface.co/datasets/ulamai/UnsolvedMedical/resolve/main/tests/test_relations.py
949 Bytes
| #!/usr/bin/env python3 | |
| """Unit tests for UnsolvedMed relations graph integrity (Section 6.12 & Section 10).""" | |
| import json | |
| import unittest | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| class TestRelations(unittest.TestCase): | |
| def test_relations_resolve_and_no_self_loops(self): | |
| bundle = json.loads((ROOT / "dataset.json").read_text(encoding="utf-8")) | |
| all_ids = {r["id"] for r in bundle["problems"]} | |
| with (ROOT / "relations" / "relations.jsonl").open("r", encoding="utf-8") as f: | |
| rels = [json.loads(line) for line in f if line.strip()] | |
| self.assertGreaterEqual(len(rels), 5000) | |
| for r in rels: | |
| self.assertIn(r["subject_id"], all_ids) | |
| if r["object_id"].startswith("UMED-"): | |
| self.assertIn(r["object_id"], all_ids) | |
| self.assertNotEqual(r["subject_id"], r["object_id"]) | |
| if __name__ == "__main__": | |
| unittest.main() | |