Project

EarthSciAST

The EarthSciML Abstract Syntax Tree format: schema, operators, coupling, and five language bindings.

Contents

This is the documentation for the older version v0.15.1. For the latest release, see v0.17.0.

run_inline_tests

Stable function · Simulation

Tier: stable · Kind: function · Topic: Simulation

JuliaTypeScriptPythonRustGo
run_inline_testsoutside profilenot exportedrun_inline_testsoutside profile

Julia

run_inline_tests(inputs; model_name, alg, reltol, abstol, base_dir, compiler, options_for)
run_inline_tests(inputs; model_name=nothing, alg=nothing, reltol=nothing,
                 abstol=nothing, base_dir=nothing, compiler=:native,
                 options_for=nothing)
    -> Vector{AssertionResult}

Run every inline test (esm-spec §6.6, including the §6.6.5 field assertions) of the selected component(s) of inputs through esm_problem and solve, and return one AssertionResult per assertion, carrying the actual value alongside pass/fail.

inputs is a path to a .esm file, a loaded EsmFile , a directory (walked recursively for *.esm, sorted), or any iterable of those. Results are concatenated in input order; models run before reaction_systems.

Per test: solve(esm_problem(input, (time_span.start, time_span.stop); compiler), alg; reltol, abstol, saveat=<assertion times>) with the test’s initial_conditions / parameter_overrides applied. Each assertion then reads the asserted variable at its time: a scalar sample, a point sample per coords (1-based index space, nearest index, exact ties rounding down), or a reduction per reduce (error norms against a reference: an analytic expression, evaluated with evaluate_cellwise , or a {type: "from_file", path, format?} JSON snapshot resolved against base_dir). base_dir defaults to the .esm file’s directory, else the working directory.

Assertion tolerances resolve per field over four levels (esm-spec §6.6.4: assertion > test > model > rel=1e-6), and the pass predicate, wall-time accounting and JUnit output (write_junit_xml ) are those of run_esm_tests (both runners share _run_test_frame!).

Keywords:

  • alg — the ODE algorithm for every document. Left nothing, each document gets Rosenbrock23 when it declares solver.stiffness: "high" (esm-spec §2.2), else Tsit5; that needs OrdinaryDiffEqRosenbrock or OrdinaryDiffEqTsit5 loaded, and a document with tests and no available solver raises an ArgumentError.
  • reltol / abstol — integration tolerances (not the assertion tolerances above). Each resolves most-specific first: an options_for override, this keyword, the document’s solver.reltol / solver.abstol, then DEFAULT_TEST_RELTOL / DEFAULT_TEST_ABSTOL.
  • compiler — passed to esm_problem for every test.
  • options_for — called once per document, before it is loaded, with its path (or the EsmFile when there is none); returns an InlineTestOptions whose non-nothing fields override the keywords for that document, or nothing.

A document that fails to load throws when inputs names a single document; in a batch (an iterable or a directory) it contributes one error row naming the path instead. r.file is the path each row’s document was loaded from ("" for an in-memory EsmFile).

Source

TypeScript

Not available in TypeScript. TypeScript is outside the simulation capability profile (Julia, Python, Rust): build an RHS and integrate it; TypeScript and Go are deliberately non-simulating.

Python

Python does not export this function.

Rust

pub fn run_inline_tests(file: &EsmFile, model_name: Option<&str>, opts: &SolveOptions) -> Vec<AssertionResult>

Run every inline test (esm-spec §6.6, including the §6.6.5 PDE assertions) of the selected model(s) of file through the official simulation pathway (crate::problem::esm_problem / crate::problem::solve , the array runtime), and return one AssertionResult per assertion — carrying the ACTUAL reduction value alongside pass/fail, so conformance harnesses can record and cross-compare the numbers.

Per test: simulate over the test’s time_span (with its initial_conditions / parameter_overrides applied and opts pinning the solver family and tolerances; the assertion times become the sampled saveat); then per assertion the asserted variable’s field is read at the assertion time and either point-sampled per its coords (positions in 1-based INDEX space; nearest grid index, exact ties rounding DOWN — the pinned cross-binding convention) or collapsed per its reduce (error norms evaluate the reference — an analytic expression cellwise via evaluate_cellwise , or a {type: "from_file", path, format?} JSON snapshot resolved against the working directory; set InlineTestOptions::base_dir to anchor at the .esm file’s directory). An assertion with neither coords nor reduce samples a scalar state. Mirrors the Julia binding’s run_inline_tests 1:1 (tolerances per §6.6.4; the pass predicate is Julia isapprox). Models iterate in sorted name order for deterministic output.

Source · Rust docs

Go

Not available in Go. Go is outside the simulation capability profile (Julia, Python, Rust): build an RHS and integrate it; TypeScript and Go are deliberately non-simulating.