Documentation

42.7 Reference data sets and fixtures

Four reference data sets carry most of the weight

What you will learn

  • Know the package's reference data sets and the truth each carries.
  • Rebuild and verify them with one command, and understand why they are read-only.
  • Build a fixture of your own: independent generation, exact writing, recorded truth, hash.
  • Choose between a small exact fixture and a larger realistic one.

Prerequisites: 42.5 Sources of truth and 42.6 Tolerance policy.

A fixture is a data set, a model and the independent expected values that go with them. Good fixtures are small enough to check by hand and varied enough to reach the cases that fail in practice. The package keeps them in data/ as controlled, read-only files produced without the program: from closed-form pharmacokinetics, independent implementations of the trapezoid rules, and seeded pseudo-random simulation by make_reference_data.py.

The catalogue

Fixture Used by Size Known truth or expected value
pop_oral1.csv/.ctl fit, vpc, cov, forest, sims, power, screen, autoinit, eda, qc, PQ, data integrity 150 subjects, 10 samples each (1500 observations), one oral dose CL 4 L/h, V 40 L, K_A 1.2 /h; IIV ω² 0.09 (CL), 0.04 (V); proportional error variance 0.0225; weight on CL (0.75) and V (1.0); AGE, SEX, EGFR and NOISE absent from the model
pop_oral1_cov.ctl fit, vpc, forest, PQ same data the same model with the weight effects estimated (THETA4 on CL, THETA5 on V)
pop_oral1_des_linear.ctl, pop_oral1_des_ode.ctl OQ-FIT-006 same data the same model as linear $DES (matrix exponential) and non-linear $DES (ODE solver)
lik_check.csv/.ctl, lik_small_omega.ctl OQ-FIT-002 8 subjects, 56 observations, one ETA exact −2 log marginal likelihood by quadrature: −144.2408 (and −118.5748 at ω² = 1e-4)
lin_amt.csv/.ctl, lin_z.csv/.ctl OQ-FIT-011, OQ-FIT-012, OQ-PWR-004 30 subjects × 6 = 180 observations OLS closed form: intercept 1.5743, slopes 0.7863 and −0.3007, residual variance 0.16153, OFV −148.1481, exact standard errors
pk_iv1_exact.csv nca 4 individuals, noise-free IV bolus AUC∞, t½, CL, V_z, V_ss, MRT, C₀ in closed form
pk_oral1_exact.csv nca 3 individuals, noise-free oral closed-form AUC∞, C_max, T_max
pk_flat.csv OQ-NCA-007 three nearly flat profiles at normal, large (3·10⁶ at t ≈ 1000) and tiny (10⁻⁹) scale AUC and AUMC to the last sample from 80-digit decimal arithmetic
sims_det.ctl sims model without variability closed-form steady-state AUC (25), C_avg, C_max, trough
qc_dirty.csv qc-data 14 individuals, 12 seeded defects, one per individual expected finding for each
bad_model.ctl, fixable_model.ctl qc-nm control streams known faults and safely fixable faults
er_study.csv, er_*.er er 1000 subjects, five response types generating coefficients for Emax, logistic, Poisson, ordinal and Cox models
cov_*.covar cov, inspect, validate, posterior candidate list WT, AGE, SEX, EGFR, NOISE on CL and V which are retained, which rejected
pop_oral1_*same*.ctl, *_fraction.*, *_advan99.ctl, *_indefinite_omega.ctl, *_unused_theta.ctl OQ-FIT-009 … 014, OQ-SIM-005 variants of the reference one deliberate fault each (page 42.14)

The expected values live in one file, expected_values.json, each with its origin in _about: closed forms, independent trapezoid sums, marginal likelihoods, true parameters, counted observations.

Why synthetic, why small

Synthetic data are used because only synthetic data have a known truth. A real data set has estimates but no generating parameters; it can show that two tools agree, never that either is right. Small data sets are used where the reference can be computed exactly: lik_check has 8 subjects and one random effect because the marginal likelihood can be integrated numerically; lin_amt is linear because the least-squares standard errors are then exact. The larger pop_oral1 carries what only size can: truth recovery with realistic shrinkage, and the end-to-end workflow.

Rebuild and verify in one command

python data/make_reference_data.py --check

The script regenerates every file in memory and compares it with the committed file, printing identical for each. The generator uses Python's Mersenne Twister with fixed seeds, whose sequence is stable across Python 3.2 and later for random.random()-based draws, so anyone can rebuild the data. The CSV, control-stream and settings files are identical on every Python version; a few sums in expected_values.json differ in the last binary digit (about 1e-16 relative) between Python 3.12 and earlier, so that one file is compared to 1e-12 and reported as equal rather than identical. Every test tolerance is 1e-9 or wider, so this cannot change an outcome.

Why the files are read-only

The runner copies what a test needs into the test's own folder; the originals are never touched. A change to any file—"even a comma"—changes the seal and needs change control: regenerate, run --check, rebuild the traceability matrix and protocols, re-seal, and re-run the tests that use the file. This looks heavy for a comma and exactly right for a decimal point.

Building a fixture of your own

Use the same five habits.

  1. Generate independently. Write a short script, with a fixed seed, that produces the data. Do not use the program to make the data it will be tested on, unless the truth is recorded and specified by the test (as in PQ-002).
  2. Write exactly. Use a lossless textual representation of every float (repr in Python). Never let the file carry fewer digits than the computation that produced the expected values.
  3. Compute expected values from the written file, not from the generator's variables.
  4. Record the truth and its origin next to the data, in one machine-readable file.
  5. Hash it. Put the file in the package manifest so that a silent edit breaks the seal.

Worked example: a one-compartment IV fixture in ten lines of reasoning

You want a fixture for a site rule on bioavailability. Choose dose 100, CL 5, V 50 (k = 0.1). Generate noise-free concentrations C(t) = (100/50) e^(−0.1 t) at t = 0.25, 0.5, 1, 2, 4, 8, 12, 24, 48, 72. The truth is immediate: AUC∞ = 100/5 = 20, t½ = ln 2 / 0.1 = 6.931, MRT = 10, C₀ = 2.

Because the profile is noise-free, the only source of difference between the program and the truth is the method: the trapezoid rule used for the observed portion, and the extrapolation from the last sample. The package's own fixture shows the size of that method difference: with the linear-up/log-down rule the AUC to the last sample is 19.9851 against the exact 20 (the missing tail), while the plain linear rule gives 20.8474, because it overestimates the area under a convex, declining curve. A test that accepted 20.0 ± 1e-6 for AUC-to-last would fail a perfectly correct program; the right reference is the rule-specific value, computed independently with the same rule. Choosing the reference at the level of the method, not the idealisation, is half the craft of fixture design.

Small exact, or large realistic?

Question Prefer
Is an exact reference available? small, exact (e.g., 8 subjects, one ETA)
Does the failure appear only with realistic sparsity, shrinkage or sample size? large, realistic, with known truth
Must a human be able to check one line by hand? small
Is the test about a workflow (many commands feeding each other)? the reference population with PQ-001's twelve steps

Use both: the exact fixture proves the arithmetic, the realistic one proves the arithmetic survives realistic data.

Review checklist

  • Does each fixture state its truth, and is that truth computed without the program?
  • Are floats written losslessly, and expected values computed from the written file?
  • Can the data be rebuilt and checked with one command?
  • Is the reference at the level of the method (rule-specific), not the idealisation?

See the previous page, the next page and the complete validation reference.