papertrail/backend/engines/PyMARE/pymare/tests/test_stan_estimators.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

38 lines
1.4 KiB
Python

"""Tests for estimators that use stan."""
import sys
import pytest
from pymare.estimators import StanMetaRegression
@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python 3.7 or higher")
def test_stan_estimator(dataset):
"""Run smoke test for StanMetaRegression."""
# no ground truth here, so we use sanity checks and rough bounds
est = StanMetaRegression(num_samples=3000).fit_dataset(dataset)
results = est.summary()
assert "BayesianMetaRegressionResults" == results.__class__.__name__
summary = results.summary(["beta", "tau2"])
beta1, beta2, tau2 = summary["mean"].values[:3]
assert -0.5 < beta1 < 0.1
assert 0.6 < beta2 < 0.9
assert 3 < tau2 < 5
@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python 3.7 or higher")
def test_stan_2d_input_failure(dataset_2d):
"""Run smoke test for StanMetaRegression on 2D data."""
with pytest.raises(ValueError) as exc:
StanMetaRegression(num_samples=500).fit_dataset(dataset_2d)
assert str(exc.value).startswith("The StanMetaRegression")
def test_stan_python_36_failure(dataset):
"""Run smoke test for StanMetaRegression with Python 3.6."""
if sys.version_info < (3, 7):
# Raise error if StanMetaRegression is initialize with python 3.6 or lower
with pytest.raises(RuntimeError):
StanMetaRegression(num_samples=3000).fit_dataset(dataset)