Skip to content

Add DRAGON cross-language parity test - #389

Open
marouenbg wants to merge 1 commit into
netZoo:develfrom
marouenbg:dragon-parity-test
Open

Add DRAGON cross-language parity test#389
marouenbg wants to merge 1 commit into
netZoo:develfrom
marouenbg:dragon-parity-test

Conversation

@marouenbg

@marouenbg marouenbg commented May 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Add a parity test that pins netZooPy's DRAGON outputs to a fixed numeric snapshot. The same shared inputs and gold values are committed byte-identical in netZooR (companion PR linked below). If both tests pass, the two implementations agree to 1e-5 absolute tolerance.

What's covered

  • lambdas (penalty parameters)
  • shrunken covariance
  • precision matrix
  • partial correlation matrix

What's not covered

  • κ estimation and p-values — these are unimplemented stubs in netZooR (estimate_kappa_dragon and estimate_p_values_dragon in DRAGON.R are empty function bodies; the public dragon() prints "not yet implemented in R; to estimate p-values, use netZooPy"). When netZooR gains a κ/p-value implementation, this parity test should be extended.

Fixtures

  • Inputs: X1.csv (50×20), X2.csv (50×15) — generated deterministically by tests/dragon_parity/regenerate.py from simulate_dragon_data(seed=20250510), then column-scaled.
  • Gold outputs: lambdas.txt, cov.csv, prec.csv, ggm.csv. Snapshot of netZooPy's pipeline at the time the fixtures were generated.
  • The same files live byte-identical at netZooR's tests/testthat/dragon_parity/.

Local results

R lambdas : 0.8032896157, 0.8167110796
py lambdas: 0.8032890169, 0.8167107609
cov   max|diff| = 2.20e-7
prec  max|diff| = 2.14e-7
ggm   max|diff| = 1.99e-7

R and Python agree two orders of magnitude tighter than the 1e-5 tolerance.

Companion PR

Test plan

  • pytest tests/test_dragon_parity.py — 2 passed locally
  • CI runs the new test alongside the rest of tests/test_dragon.py

🤖 Generated with Claude Code

Add a parity test asserting that the netZooPy DRAGON pipeline (lambdas,
shrunken covariance, precision matrix, partial correlation matrix)
matches a fixed snapshot. The same shared inputs and gold values are
mirrored in netZooR's tests/testthat/dragon_parity/ -- if both tests
pass, the two implementations agree to 1e-5 (atol).

Inputs are generated deterministically by tests/dragon_parity/regenerate.py
from simulate_dragon_data with seed=20250510, then byte-identical CSVs
are committed to both repos.

Kappa / p-values are not covered, since netZooR's estimate_kappa_dragon
and estimate_p_values_dragon are unimplemented stubs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@katehoffshutta katehoffshutta added the ai-contrib Some or all of this code is written by AI and requires a human review. label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-contrib Some or all of this code is written by AI and requires a human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants