| |
| """Self-checks for this dataset release. Run: python test_package.py |
| Only needs the two jsonl files (no panels, no network).""" |
| import collections |
| import hashlib |
| import json |
| import os |
|
|
| HERE = os.path.dirname(os.path.abspath(__file__)) |
|
|
| rows = [json.loads(l) for l in open(os.path.join(HERE, "train_labels.jsonl")) if l.strip()] |
| assert len(rows) == 686, len(rows) |
| assert len({r["id"] for r in rows}) == 686, "ids duplicados" |
| labels = collections.Counter(r["label"] for r in rows) |
| assert labels == {"positive": 541, "negative": 110, "unsure": 35}, labels |
| splits = collections.Counter(r["split"] for r in rows) |
| assert splits == {"train": 651, "excluded": 35}, splits |
| train = collections.Counter((r["scroll"], r["label"]) for r in rows if r["split"] == "train") |
| assert train == {("s1", "positive"): 541, ("s1", "negative"): 87, ("s2s3", "negative"): 23}, train |
| assert all(r["win"] == 512 for r in rows if r["scroll"] == "s1") |
| required = {"id", "scroll", "panel_or_segment", "y", "x", "win", "label", "round", "source_file", "split", "weight"} |
| assert all(required <= set(r) for r in rows), "fila sin campos requeridos" |
|
|
| fib = [json.loads(l) for l in open(os.path.join(HERE, "fiber_negatives_50.jsonl")) if l.strip()] |
| assert len(fib) == 50 and len({r["id"] for r in fib}) == 50 |
| assert all(r["label"] == "negative" and r["weight"] == 1.0 and r["win"] == 512 for r in fib) |
| VAL = {"20260623144224-w046-052", "20260623145652-w059-063", "20260623154006-w085-088"} |
| assert sum(1 for r in fib if r["panel_or_segment"] in VAL) == 12, "deben ser 12 en val" |
|
|
| idx = os.path.join(HERE, "full_index_complete.json") |
| if os.path.exists(idx): |
| sha = hashlib.sha256(open(idx, "rb").read()).hexdigest() |
| assert sha == "4d393d70ce886ed62b7e73e365f1d01cbe7f6efa37168fb3f27ade2b89d6e7a8", sha |
|
|
| print("test_package: OK (686 labels + 50 fiber negatives + index sha256, conteos y esquema verificados)") |
|
|