Architecture — synaptome¶
synaptome (distributed as
mindmap-synaptome, part of the mindmap collection; imported assynaptome) is a Python library that keeps a research study's analysis-ready data in one portable object: who ran it and how (identity, protocol), which units were observed (a hierarchy such assite > subject > session), what each variable means (a strict data dictionary), and the values themselves. AStudycan be saved as an open.synfile (Parquet + JSON) and handed to a collaborator. A separate, array-level statistics engine (engine/) provides the tests, estimators, confidence intervals, bootstrap, corrections and cluster permutation that analyses will use.datasets/builds toy studies with planted effects, one per study design.questions/turns "compare X by Y" into a resolved design (paired or independent, groups, pairs, n) and an analysis table.estimates/answers "how large?" andhypotheses/"is there a difference?" (two-group, omnibus, cluster and normality tests), asresults/values that carry their question, data fingerprint and pre-registration timing (study.verify,.synrfiles, formatted tables, corrections across results). The protocol stores pre-specified questions with an amendment log.plot/draws data and results with plain Matplotlib. The documentation site (docs/,mkdocs.yml) renders concepts, the executed tutorials and the API reference.
1. Big picture¶
flowchart LR
user([User code / notebook])
study[Study<br/>study/study.py]
units[UnitHierarchy<br/>study/units.py]
vars[VariableDictionary<br/>study/variables.py]
store[ValueStore<br/>study/values.py]
meta[StudyInfo · Protocol · Attachments]
syn[(.syn folder / zip<br/>io/syn.py)]
engine[engine/<br/>plain arrays]
question[Question · Design<br/>questions/]
estimate[estimates/ registry + runner]
test[hypotheses/ registry + runner]
result[Estimate · Pairwise · Omnibus ·<br/>Cluster · Normality · Describe<br/>results/]
synr[(.synr file)]
user -->|add, add_units, to_df, select| study
user -->|compare, compare_along, distribution| question
question -->|to_df, units, reducers| study
question -->|q.estimate| estimate
question -->|q.test| test
test -->|effect sizes| estimate
test -->|engine tests| engine
estimate -->|engine functions| engine
estimate --> result
test --> result
user -->|syn.correct| result
result <-->|save / load_result| synr
result -.->|study.verify| study
study --> units
study --> vars
study --> store
study --> meta
study <-->|save / load / peek| syn
user -.->|arrays from to_df| engine
Study is the only object users normally touch. It owns four parts that know nothing about each other's
internals: the unit hierarchy, the variable dictionary, the value store, and descriptive metadata. io/syn.py
reads and writes the whole thing. engine/ is standalone: it works on NumPy arrays, and nothing in study/
calls it; estimates/ and hypotheses/ call it on a question's data.
2. Components¶
| Component | Path | Responsibility | Talks to |
|---|---|---|---|
| Public API | src/synaptome/__init__.py |
Exports Study, concat, load, peek, InferenceNotice, datasets, load_result, correct, and plot (imported on first use) |
study, io, datasets, results, plot |
| Study | src/synaptome/study/study.py |
Container; add/add_units, views (to_df, table, describe, with reduce= and joins up the hierarchy), manipulation (select, drop, rename, copy, concat), save; entry points compare / compare_along / distribution / question / verify and plot (lazy); protocol property binding the protocol to the study |
all of study/, io/syn.py, lazily questions/, plot/ |
| Reducers | src/synaptome/study/reduce.py |
parse_reduce, reduce_dim, reduce_level: named reductions (mean … slope, auc, ("at", c)) on long tables |
— |
| Unit hierarchy | src/synaptome/study/units.py |
Levels as a DAG (nesting and crossing), shorthand parser ("a > b", "t < s * x"), unit id tables, internal unit keys, path resolution between levels |
— |
| Variable dictionary | src/synaptome/study/variables.py |
Dim (with kind for replicate axes), Variable (with replicates_of), VariableDictionary: definitions, inference from first values, strict validation, replicate links |
units (level names) |
| Value store | src/synaptome/study/values.py |
One long table per variable (_uid, dimension columns, value); added_at / first_added_at; InferenceNotice |
— |
| Identity & plan | src/synaptome/study/info.py, protocol.py |
StudyInfo/Person, Protocol/Arm dataclasses with to_dict/from_dict; the protocol's pre-specified questions (Registration: spec, status, registered_at), add_question / remove_question with the amendment log, questions rebuilt on the bound study, match |
study.question (lazy) |
| Attachments | src/synaptome/study/attachments.py |
Embedded files or path references, both with SHA-256 checksums | — |
| Storage | src/synaptome/io/syn.py |
.syn writer/reader (format 2: questions/, first-added times; reads format 1), peek, partial load(variables=...) |
study/* |
| Atomic writes | src/synaptome/io/_atomic.py |
atomic_replace: write elsewhere, then swap in |
— |
| Engine | src/synaptome/engine/ |
Hypothesis tests, estimators and effect sizes, analytic and bootstrap intervals, p-value correction, effective sample size, cluster permutation | NumPy/SciPy only |
| Toy studies | src/synaptome/datasets/toy.py |
Eight seeded generators (case_control, crossover, longitudinal, simulation_benchmark, timepoint_pairing, repeated_trials, crossed, method_comparison), each returning a fully defined Study; planted effects (real and null) in study.info.extra["planted"] |
study (public API only) |
| Questions | src/synaptome/questions/ |
Question base (base.py: roles, validation, to_dict/from_dict, memoized design / data / data_key, pair_data); kinds Compare, CompareAlong, Distribution; resolve.py (subset → reduce → paired/independent → analysis table, guard rails); design.py (Design); fingerprint.py (data_key) |
study (public API: to_df, units, reducers) |
| Estimates | src/synaptome/estimates/ |
registry.py: one Estimator per estimator (family group / pair / omnibus, designs, scales per design, min_groups, binary, engine function, analytic interval, bounded, flip); requirements.py: checks shared with tests (scale wording, fitting estimators, serial-correlation summary, assume_independent); run.py: compute_estimate checks the estimator against q.design (guard rails naming alternatives) and computes rows with analytic / bootstrap / upstream-replicate intervals (optionally returning the draws); group_samples builds one sample per group for omnibus statistics |
engine, questions |
| Tests | src/synaptome/hypotheses/ |
registry.py: one Test per test (answers, designs, scales, binary, engine call, params, default effect sizes, ordered-unit rule, offset, result kind, min_groups, default correction); run.py: compute_test checks the test against q.design and dispatches on its result kind: per pair on q.pair_data (pairwise), once on all groups (omnibus), per pair on curves (cluster), per group or per pair of differences (normality); effect sizes through compute_estimate; correction_columns, cluster_correction |
engine, estimates, questions |
| Results | src/synaptome/results/ |
base.py: Result (question spec, method, table, extra tables, data_key, times, versions), to_frame / to_markdown, .synr save, load_result; estimate.py: EstimateResult with vs(), run_estimate; tested.py: TestResult, RowsResult (correct of one p per row); pairwise.py: PairwiseResult (vs, differences, draws); omnibus.py, normality.py; cluster.py: ClusterResult (correct(family=), verdict, curve, null, vs); describe.py: DescribeResult, run_describe; run.py: run_test (result type from the registry); correct.py: syn.correct (one family across results); format.py: APA p values, estimate cells, Markdown tables and notes for every type; timing.py: timing(question) (registration vs first data) stamped on every result |
estimates, hypotheses, io/_atomic |
| Plots | src/synaptome/plot/ |
accessor.py: PlotAccessor (study.plot), the data views and thin result-view methods, draw_categorical; results.py: the result views (comparison, differences, along, estimate / forest, normality, omnibus), the stale-result check, plot_result (result.plot()); _data.py: the frame a view draws (view_frame: subset, reduce, unit collapse, pooling record), summaries (ci through the estimator registry), box statistics, ECDF, Bland–Altman; _draw.py: matplotlib renderers, no statistics; style.py: font size, stable colours; figure.py: Plot |
study (public API), estimates, _utils |
| Docs site | docs/, mkdocs.yml |
Concept pages, docs/tutorials → ../tutorials (executed at build), API reference pages (synaptome.<package>), development pages included from ARCHITECTURE / CONTRIBUTING / CHANGELOG; docs/_hooks/notebook_links.py rewrites links between tutorials |
the package (docstrings), tutorials/ |
| Helpers | src/synaptome/_utils.py |
JSON-safe conversion, filter freezing/serialization, match_values (subset/select matching) |
— |
Engine files¶
| File | Contents |
|---|---|
engine/hypothesis.py |
StatResult; paired_test (Wilcoxon with zero_method, t, t with effective n, exact McNemar), independent_test (Mann-Whitney, Student, Welch), both with offset; normality, omnibus_paired, omnibus_independent |
engine/effect_sizes.py |
Estimators: mean_diff, hodges_lehmann, prop_diff, odds_ratio; Cohen's d/dz, Hedges' g/gz, CLES, rank-biserial, Kendall's W, η², partial η² (RM), ε² |
engine/intervals.py |
Analytic CIs: t (optional n_eff), Welch, signed-rank and Mann-Whitney (Hodges-Lehmann), exact binomial (median), Wilson, Newcombe, odds ratio |
engine/bootstrap.py |
bootstrap_draws, bootstrap_interval (percentile, basic, BCa), bootstrap_pvalue (matches the interval), bootstrap_bias, jackknife acceleration, bootstrap_ci (one call, accepts pre-computed draws) |
engine/correction.py |
correct_pvalues (none, Bonferroni, Holm, BH, BY) |
engine/ess.py |
effective_sample_size for serially correlated samples |
engine/cluster.py |
cluster_permutation (1-D, paired sign flips or independent label shuffles, exact enumeration when small) → ClusterStatResult |
Each estimator follows one signature per family: one sample f(x), paired f(x, y, paired=True) (or
f(x, y) for paired-only estimators), independent f(a, b). Positive always means the first sample is
larger. Placeholder packages for the later layers (hypotheses/, plot/, and the test result modules of
results/) hold only a docstring naming the step that builds them.
3. Main flow: adding values, then saving¶
study.add("weight", df)(study/study.py). The input is either a long DataFrame (unit id columns, dimension columns, value column) or an array for one unit, with ids and coordinates passed as keywords (converted by_array_to_frame).- Level and dimensions. If the variable is new, its level comes from the id columns
(
_infer_level) and its dimensions from the remaining columns.Variable.infer(study/variables.py) guesses the dtype, and anInferenceNoticewarning shows the definition. If the variable already exists, the given dimensions are checked against its definition. - Validation.
Variable.validatechecks dtype, categories and range.study.additself rejects missing coordinates and duplicate addresses. - Units. The first data that mentions a level creates that level's units. Afterwards, unknown ids
raise unless
create_units=True.UnitHierarchy.lookupturns the id columns into internal_uids. - Storage.
ValueStore.put(study/values.py) appends the rows. Writing to an address that already holds a value raises unlessoverwrite=True. - Rollback. On any error, the unit tables are restored from a snapshot and a newly inferred
definition is dropped, so a failed
addleaves the study unchanged. study.save("trial.syn")→io/syn.save._write_treewrites the files listed below into a temporary folder, which is then zipped (path ends in.syn) or renamed into place. Only an existing synaptome save is ever overwritten.units/<level>.parquetvalues/<variable>.parquet, each carrying its variable definition in Parquet metadataquestions/<title>.json, the protocol's pre-specified questionsstudy.json(info, protocol with its amendment log, levels, dictionary, first / last added times)manifest.json(format 2; format 1 still loads)syn.load(path)reverses this. It rebuilds levels, units and definitions, then replays the values throughstudy.add(..., create_units=False), so hand-edited files are validated again.
Asking a question¶
study.compare("error", by="method", subset=..., reduce=...)(study/study.py) importsquestions/and builds aCompare. Creation checks names only (outcome,by, reducers), so a question can exist before its data.- First access to
q.design/q.datacallsquestions/resolve.resolve: to_df(outcome)gives the raw long table;subsetfilters coordinates, unit ids, or units by a scalar variable (match_values);- the unit is fixed (given, or the level the reductions lead to), and every level between the outcome and the unit must be reduced (pseudo-replication guard);
byis classified: a dimension → within-unit factor (paired); a variable at the unit's level → between-unit factor (independent); a variable at a level crossed with the unit → within-unit (paired); anything else raises;- unused dimensions must be reduced or left with one coordinate; reductions run in the order written
(
reduce_dim,reduce_levelfromstudy/reduce.py); - the analysis table (unit ids,
by,along, outcome) and theDesign(groups, pairs, n per pair on complete cases, scale) are built. - The result is memoized on the question.
q.data_key(questions/fingerprint.py) hashes the sorted table and the meaning-bearing fields of the definitions read. q.to_dict()records the roles (no values);study.question(spec)rebuilds it on any study.
Computing an estimate¶
q.estimate("hodges_lehmann", ci="analytic")(questions/base.py) importsresults/estimate.py(results sit above estimates) and callsrun_estimate.estimates/run.compute_estimatelooks the estimator up (estimates/registry.py) and checks it againstq.design: question kind (pairs needcompare), paired / independent, binary, scale, ordered unit, interval availability. Each refusal names the estimators or settings that fit.- Rows come from
q.data(per group) orq.pair_data(a, b)(per pair), peralongcoordinate. Analytic intervals are the registry's engine functions (n_efffor an ordered unit); bootstrap usesengine.bootstrap_draws/jackknife_*/bootstrap_intervalwith the recorded seed, or the draws of a replicate variable, resolved like the outcome (resolve(..., keep=(draw_dim,))). run_estimatewraps the table and method in anEstimateResultwith the question'sto_dict(),data_key, time and versions.result.save()writes a.synrzip;study.verify(result)rebuilds the question on the current study and comparesdata_key.
Running a test¶
q.test("wilcoxon", alternative="less")(questions/base.py) importsresults/run.pyand callsrun_test, which picks the result type from the registry'sresult(pairwise, omnibus, cluster, normality).hypotheses/run.compute_testlooks the test up (hypotheses/registry.py) and checks it againstq.design: kind (compare), paired / independent, binary, scale, the ordered-unit rule (refused with the measured effective sample size unlessassume_independent=True;ttest_essonly there),offset.- Per pair, the engine test runs on
q.pair_data(a, b);bootstrapinstead takes its estimator's draws fromcompute_estimate(..., return_draws=True)and reads the p value withengine.bootstrap_pvalue. Effect sizes arecompute_estimatetables joined on the pair, so they equalq.estimate. The p values are corrected across the pairs (engine.correct_pvalues). Omnibus tests readgroup_samples(one matched sample per group); cluster tests pivot each pair to units × coordinates inalongorder and callengine.cluster_permutation(corrected bycluster_correction, family"cluster"or"pair"); normality tests read per group, or each pair's differences when paired. run_testwraps it in its result (extra tables such asdraws,pairs,curve,nullsaved in.synr).q.describe()goes throughresults/describe.run_describeinstead.result.correct(...)andsyn.correct([...])(one family across results) return new results;to_markdown()/to_frame(pretty=True)format it throughresults/format.py.
Pre-specifying a question¶
study.protocol.add_question(q, status="primary")(study/protocol.py) storesq.to_dict()with its status and the current time (Registration). Only names are checked, so it works before any value.study.savewrites each registration toquestions/<safe title>.json, the amendment log and the first / last added times tostudy.json(io/syn.py);loadrestores them,peeklists them.study.protocol.questions[title]rebuilds the question withstudy.question(spec)on the current data (the protocol is bound to its study by theStudy.protocolsetter).- Every result is stamped by
results/timing.timing(question):protocol.match(same title and analysis) gives the registration; the variables read are the resolved definitions; "before data" when the registration precedes the earliestfirst_added_atamong them.
Drawing a data view¶
study.plot.violin("error", x="method", subset=...): thestudy.plotproperty importsplot/lazily and returns aPlotAccessor._data.view_framereadsstudy.to_df(var, with_=..., reduce=...), filters withsubset, collapses to one value perunitif asked, and records what is pooled (values, units, dimensions left)._data.summary_tablecomputes what is drawn (centers, intervals, box statistics); colours come fromstyle.colors(position among all levels of the variable)._drawrenders those numbers only; the view returns aPlotwithdata,pointsandartists.
Drawing a result¶
r.plot()(results/base.py) importsplot/results.plot_result, which picks the view for the type and draws onr.question.study;study.plot.comparison(r)etc. draw on that study._checkrebuilds the question fromr.question_specon the study and comparesdata_key: a mismatch raises (out of date).- The view draws the question's data (
question.data,pair_data,draws,curve) through the same_data/_drawhelpers as data views, and the result's own numbers (verdicts, effect sizes oriented withvs()); brackets, annotations, forest rows and cluster bars are inPlot.data/artists.
4. Data model¶
erDiagram
Study ||--|| StudyInfo : info
Study ||--|| Protocol : protocol
Study ||--|| UnitHierarchy : units
UnitHierarchy ||--|{ Level : levels
Level }o--o{ Level : "parents (DAG)"
Study ||--|| VariableDictionary : variables
VariableDictionary ||--o{ Variable : defines
Variable }o--|| Level : "attached to"
Variable ||--o{ Dim : "shape"
Variable |o--o{ Variable : "replicates_of"
Variable ||--o{ Value : "observed as"
Study ||--o{ Attachment : attachments
Protocol ||--o{ Registration : "pre-specified questions"
A value's address is (unit at the variable's level, a coordinate on each dimension). Unit attributes such as
group, age and sex are not a separate concept. add_units stores them as scalar variables at that level.
5. Where do I change X?¶
- Add a variable field (e.g. a new metadata key) →
Variableinstudy/variables.py. It must also round-trip throughto_dict/from_dict. - Change what counts as a valid value →
Variable.validateand the_to_*converters instudy/variables.py. - Change dtype or level inference →
_infer_dtypeinstudy/variables.py,Study._infer_levelinstudy/study.py. - Change the level shorthand or hierarchy rules →
UnitHierarchy.define/add_level/pathsinstudy/units.py. - Add a view or manipulation (
to_df,table,select, …) →study/study.py. - Add a reducer →
REDUCERSandreduce_diminstudy/reduce.py(andLEVEL_REDUCERSif it makes sense for unordered units). - Change how levels are reduced or joined →
Study._reduce_frame,_reduction_chain,_joininstudy/study.py. - Change replicate rules →
Variable.__post_init__and_check_replicateinstudy/variables.py; dependents are guarded inVariableDictionary.update/remove. - Change the on-disk format →
io/syn.py(_write_tree,load). BumpFORMAT_VERSIONwhen old readers would misread the files. - Add a statistical test or estimator →
engine/hypothesis.pyorengine/effect_sizes.py; an analytic interval →engine/intervals.py. Export it inengine/__init__.py. - Change how bootstrap intervals or p-values are read from draws →
engine/bootstrap.py(bootstrap_intervalandbootstrap_pvaluemust stay consistent with each other). - Add a study-level field (ethics, funding, …) →
study/info.pyorstudy/protocol.py. - Add or change a toy study →
datasets/toy.py(export it indatasets/__init__.py). It must define every variable explicitly, list its planted effects (with at least one null) in the docstring and in_planted(...)entries, and get a recovery test intests/unit/test_datasets_toy.py. - Add a question kind → a
Questionsubclass inquestions/with itskind,_role_namesand_check_roles; resolution goes throughquestions/resolve.py; add an entry point instudy/study.py. - Change how paired / independent is decided, or a guard rail →
_classify_byand the checks inresolve()(questions/resolve.py); error wording uses between-/within-unit factor vocabulary. - Change what
data_keydepends on →_FIELDS/_DIM_FIELDSinquestions/fingerprint.py(bumpVERSIONif old keys must stop matching). - Change a dimension's ordering rules →
Dim.effective_scaleandcheck_dim_coordinates(study/variables.py), the scale checks inreduce_dim(study/reduce.py). - Add an estimator → an
Estimatorentry inestimates/registry.py(engine function per design, analytic interval if any, scales,bounded,flip); the runner andvs()pick it up. - Change an estimator guard rail →
_check_requirementsinestimates/run.py; wording shared with tests (scales, serial correlation,assume_independent) inestimates/requirements.py. - Add a test → an engine function (
engine/hypothesis.py) and aTestentry inhypotheses/registry.py(answers, designs, scales, binary, params, default effect sizes,result);compute_testand the result type pick it up. A new kind of result needs a_<kind>_rowsbuilder inhypotheses/run.py, a class inresults/registered inresults/run._RESULTS, and itspretty_*/ notes inresults/format.py. Give the test a statistic symbol and a name inresults/format.py. - Change summary statistics →
results/describe.py(columns per scale in_INTERVAL/_ORDINAL/_BINARY). - Change the cluster correction families →
cluster_correctioninhypotheses/run.py(used by the runner andClusterResult.correct). - Change a test guard rail →
_check_requirements/_check_offset/_effect_sizesinhypotheses/run.py. - Change how p values are corrected or pooled →
engine/correction.py(methods),PairwiseResult.correct(one result),results/correct.py(across results). - Change pre-specified questions or amendments →
Protocol.add_question/remove_question/matchinstudy/protocol.py; their storage in_write_tree/load(io/syn.py); the timing rule inresults/timing.py(andtiming_noteinresults/format.py). - Add or change a data view →
plot/accessor.py(arguments, layout),plot/_data.py(numbers),plot/_draw.py(artists). Keep statistics out of_draw.py. Baselines: regenerate withpytest --mpl-generate-path=tests/unit/baseline -k imageand check the images. - Add or change a result view →
plot/results.py(and its thin method inplot/accessor.py, itsresult.plot()mapping in_VIEWS); annotation text inplot/_data.py(annotation_lines). - Change colours or fonts →
plot/style.py(colors,set_style,STYLE). - Add a documentation page →
docs/and thenavofmkdocs.yml; a public name → its package's__all__and a NumPy docstring (it then appears indocs/reference/); tutorials are in the site through thedocs/tutorialssymlink, and links between them are rewritten bydocs/_hooks/notebook_links.py. - Change formatted tables →
results/format.py(format_p,format_number,pretty_pairwise,pretty_estimate, the notes);Result.to_frame/to_markdowninresults/base.py. - Change what a result stores or how
.synris written →results/base.py(to_dict,save,load_result; bumpRESULT_FORMAT_VERSIONfor incompatible changes). - Change how
vs()reorients →EstimateResult.vsand_flipinresults/estimate.py,PairwiseResult.vsinresults/pairwise.py(also flipsalternativeandoffset). - Change a public API used in a tutorial → update the notebook in
tutorials/in the same change. Notebooks are committed without outputs;tutorials/README.mdlists them in order.
6. Key decisions¶
- Definitions are separate from values. A variable is defined once and observed many times, which makes strict validation possible.
- Validation is strict after the first values. Inference makes quick work easy, and strictness afterwards catches typos in ids and categories.
- Within-unit factors are dimensions, between-unit factors are variables. Analyses can then tell paired from independent data without being told.
- Repetitions are unit levels. Trials, seeds and folds go in the unit hierarchy, not in dimensions, so collapsing them is an explicit step.
- The hierarchy is a DAG, not a tree. This is needed for crossed designs (
trial < subject * stimulus). - Ids are stored as given and made unique internally. "Trial 1" can repeat under every subject.
- Storage is Parquet + JSON. Any Parquet reader (pandas, R, DuckDB) can open the data without synaptome.
- Saves are atomic, and only synaptome saves are overwritten. A crash or a typo'd path can't destroy data.
engine/works on arrays and does not depend onStudy. It is testable on its own and reusable outside the study model. It needs no MNE: the cluster permutation is plain NumPy/SciPy.- A test's
offsetmoves only the p-value. Effect sizes always describe the raw difference;alternativestays two-sided unless asked. - Reductions are explicit. Views and questions never average repetitions silently:
table(level)refuses a variable with several values per unit untilreduce=says how to collapse them. - Joins only go up the hierarchy. Each row then gets exactly one value; one-to-many relations must be reduced first.
- Upstream resampling is a replicate variable, not a unit level. Draws aren't independent units;
replicates_oflinks them to the variable they resample. - synaptome never processes data. Values arrive already derived; provenance is documented, not run.
- Questions read the design off the data model. Nobody passes
paired=True: wherebylives (a dimension, a variable at the unit's level, a variable at a crossed level) decides. Reductions are never guessed, and each pair of a comparison keeps its own complete cases. - Questions use only the study's public API.
resolve.pybuilds onto_df,unitsand the reducers; thestudy.compare-style entry points importquestions/lazily, the only upward reference. - Estimates refuse what doesn't fit. Scale, binary outcome, design and serial correlation are checked before computing, and the error lists what fits: guard rails are a feature for users who aren't statisticians. Bootstrap is seeded by default, so every result is reproducible.
- Serial correlation is refused, with a recorded override. An ordered unit (
unit="time") refuses tests and intervals that assume independence, naming the effective sample size;ttest_essis allowed, andassume_independent=Trueis recorded in the result and its tables. synaptome can't check independence, so the user states it. - Omnibus and pairwise tests are separate calls. Nothing runs behind the user's back after a significant omnibus test; normality tests are diagnostics, uncorrected by default.
- Timing is recorded by synaptome, not declared. "Before data" compares the protocol's own registration time with the first time each variable read got values; amendments are logged and re-timed.
- A result is drawn only on its own data. Result views rebuild the question and refuse a changed
data_key; they draw the result's verdicts, never re-test. - Figures compute nothing they don't report. Plain matplotlib (no seaborn);
_data.pycomputes every number drawn andPlot.datareturns it. Data views pool and say so; questions guard the statistics. - Corrections make new results.
result.correctandsyn.correct([...])(one family pooled across results, e.g. per sensor type) never change a result in place; the family is recorded inmethod["correction"]. - Results are values. A result holds its question's spec and the
data_keyit read; nothing is cached in the study.study.verify(result)re-asks the question and compares keys. - Toy studies carry their own truth. Planted effects live in
study.info.extra["planted"], shaped like the question that recovers them (outcome,by,contrast,value, optionalsubset/reduce/unit/along), so they survive save/load and tests read them instead of hard-coding numbers. - Scale (2026-11, laptop).
method_comparison(n_sources=7000), about 1.95 M values, the size of the mindmap-bem manuscript: generating and adding 0.9 s,to_df(reduce={"source": "median"})0.1 s,save0.3 s (19 MB),load0.8 s (0.4 s for one variable). Adding one subject at a time costs about 4x one batch, since eachaddmerges with what is stored; append per subject or run, not per sample.
7. Glossary¶
- Level: a kind of unit (
subject,session,trial). Levels form a DAG through their parents. - Unit: one member of a level, with an id and links to its parents. Always a statistical unit; the unit of
measurement of a variable or dimension is its
measurement_unit("kg","ms"). - Variable: a defined quantity attached to one level, with a dtype, a scale and optional dimensions.
- Dimension (
Dim): an ordered or within-unit axis of a variable (time, channel, condition). It is not a unit level. - Address: (unit, coordinates). Exactly one value lives at each address.
- Replicate variable: resampled values of another variable (
replicates_of), with one extra dimension of kindreplicate(bootstrap draw) orjackknife(left-out unit). - Reduction: collapsing a dimension or a unit level to one value with a named reducer (
reduce=). - Inferred definition: a definition guessed from the first values and flagged with
InferenceNotice. .syn: the storage layout, as a folder or an uncompressed zip.- Question: what is compared on which data (
outcome,by,subset,reduce,unit, ...); no numbers, no test. Design: what a question resolves to (paired or independent, groups, pairs, n). - Between- / within-unit factor: a factor constant within each unit (a variable at the unit's level) or varying within it (a dimension, or a variable at a crossed level); gives independent / paired comparisons.
data_key: the fingerprint of the data a question read.- Estimate / result: an answer to "how large?" (
EstimateResult), withconfidenceintervals; a result is a plain value with its question, method, table anddata_key, saved alone as a.synrfile. vs(): a pair estimate or test reoriented around the reference so that positive means the reference is better (a test'salternativeandoffsetturn with it).- Test /
PairwiseResult: an answer to "is there a difference?", one row per pair with p, corrected p, verdict and effect sizes. Family: the p values corrected together (a result's pairs, or several results withsyn.correct). - Omnibus test: one test of all the groups at once ("do they differ at all?"). Cluster: neighbouring coordinates whose t passes the cluster-forming threshold; its mass is the sum of their t.
- Registration / amendment: a question pre-specified in the protocol, with the time synaptome recorded; a logged replacement or removal of one. Timing: before data / after data / not pre-specified / unknown.
- Data view /
Plot: a figure of a variable's values (study.plot.<view>), and what it returns (axes, numbers drawn, artists). Pooled: values of dimensions or levels not on the axes drawn together. assume_independent: the recorded statement that positions along an ordered unit are independent.- Dimension scale:
Dim.scale; numeric coordinates are interval by default, others nominal. - Toy study / planted effect: a generated study from
synaptome.datasets, and a true difference (or a null, 0) built into it on purpose, recorded instudy.info.extra["planted"].
8. Testing strategy¶
- Tests live in
tests/unit/test_<package>_<module>.py, one file per module. Run them withpytest. Warnings are errors (filterwarnings = ["error"]inpyproject.toml). - Lint and format with
ruff check .andruff format --check .. - CI (
.github/workflows/ci.yml) runs lint, then the tests on Python 3.10–3.13 with coverage. It also runs the tutorials (tutorials/NN_topic.ipynb) withpytest --nbmake tutorials. They double as end-to-end checks of the public API. Adocsjob builds the site withmkdocs build --strict(tutorials executed, griffe warnings on docstrings are errors);.github/workflows/docs.ymlpublishes it to GitHub Pages on pushes tomain. tests/unit/test_public_api.pychecks that every public name and method has a docstring (the API reference has no empty entry) and thatimport synaptomedoesn't load Matplotlib.- Figures:
Plot.datais tested in the default run; six image baselines (tests/unit/baseline/) are compared withpytest --mpl.
9. Further reading¶
DESIGN.md: the agreed model and API, and the dated decisions log (§14).PLAN.md: the build order. Steps 0–15 are done; 16 is the release.tutorials/: notebook 00 covers installation; 01–05 walk through the study, units, variables (including replicate variables), values, views (includingreduce=) and storage; 06 covers the engine on plain arrays; 07 the toy studies; 08 questions; 09 estimates; 10 tests and corrections; 11 comparing along a dimension; 12 pre-registration; 13 plotting.- The documentation site (
docs/): concept pages, the tutorials executed, the API reference;README.md,CHANGELOG.md,CONTRIBUTING.md.