papertrail/backend/engines/pykeen/tests/test_generation.py
caelum0x 174222bcaa feat: Builder-Track named-user tools, bio + evidence-intelligence platform, Apache-2.0
Builds PaperTrail from the base skeleton into a full evidence-verification platform
for the "Built with Claude: Life Sciences" hackathon (Builder Track).

New named-user features (Build Beyond the Bench):
- Lab Notebook Companion — rough bench notes -> structured, searchable, grounded
  experiment records (lib/labNotebook, /console/lab-notebook, migration 0059)
- Clinical Trial Matcher — de-identified patient notes -> ranked eligible
  ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning
  (lib/trialMatcher, /console/trial-matcher, migrations 0060)

Platform:
- Deterministic verification moat (biostats recompute, exact-span grounding)
- 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar,
  PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier)
- Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise
  governance (RBAC, /api/v1 gateway, metering, audit chain, retention)
- 17 OSS projects assimilated into native TypeScript on our stack (backend/engines
  retained + credited in NOTICE)
- Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site
- Next.js 16 upgrade, benchmark harness (honest smoke-test caveat)

Licensing: Apache-2.0 (LICENSE + NOTICE).
2026-07-10 16:23:13 +03:00

45 lines
1.6 KiB
Python

"""Tests for generating triples."""
import unittest
from pykeen.triples.generation import generate_triples, generate_triples_factory
from pykeen.triples.utils import get_entities, get_relations
class TestGenerate(unittest.TestCase):
"""Tests for generation of triples."""
num_entities: int = 33
num_relations: int = 7
num_triples: int = 101
def assert_consecutive(self, x: set[int], msg=None):
"""Assert that all of the things in the collection are consecutive integers."""
assert set(range(len(x))) == x, msg
def test_compacted(self):
"""Test that the results are compacted."""
for random_state in range(100):
x = generate_triples(
num_entities=self.num_entities,
num_relations=self.num_relations,
num_triples=self.num_triples,
random_state=random_state,
)
assert self.num_triples == x.shape[0]
self.assert_consecutive(get_entities(x))
self.assert_consecutive(get_relations(x))
def test_generate_triples_factory(self):
"""Test generating a triples factory."""
for random_state in range(100):
tf = generate_triples_factory(
num_entities=self.num_entities,
num_relations=self.num_relations,
num_triples=self.num_triples,
random_state=random_state,
)
assert self.num_triples == tf.mapped_triples.shape[0]
self.assert_consecutive(get_entities(tf.mapped_triples))
self.assert_consecutive(get_relations(tf.mapped_triples))