Experiment directives¶
directives
¶
{experiment} directives: results woven into a literate document.
A directive is a fence whose info string is {experiment} and the name of
an experiment of the document's module::
```{experiment} fit_boolean
:hash: 3f2a...
:program: 9c41...
responses: mean 0.734 sd 0.051
```
Weaving (qvr weave) runs the experiment, or reads its stored record, and
writes the body: the experiment's hash, the hash of the program it ran, and
the result. The hash makes every woven number traceable to the exact
program, data, and configuration that produced it, and a woven result whose
recorded hash is no longer the experiment's hash is stale and refused.
DIRECTIVE
module-attribute
¶
DIRECTIVE = re.compile('^(?P<indent>[ \\t]*)```\\{experiment\\}[ \\t]+(?P<name>[A-Za-z_][A-Za-z0-9_.]*)[ \\t]*\\n(?P<body>.*?)^(?P=indent)```', re.M | re.S)
An {experiment} directive fence: its indentation, experiment, and body.
ExperimentDirective
didactic-model
¶
ExperimentDirective(*, experiment: str, line: int, column: int, indent: str, start: int, end: int, body: str, recorded_hash: str = '')
Bases: Model
One {experiment} directive of a document.
| PARAMETER | DESCRIPTION |
|---|---|
experiment
|
The experiment it weaves.
TYPE:
|
line
|
The 1-based line of the opening fence.
TYPE:
|
column
|
The 0-based column of the experiment's name.
TYPE:
|
indent
|
The fence's indentation.
TYPE:
|
start
|
The character offset of the body in the document.
TYPE:
|
end
|
The character offset one past the body.
TYPE:
|
body
|
The body with the indentation removed.
TYPE:
|
recorded_hash
|
The
TYPE:
|
experiment_directives
¶
experiment_directives(text: str) -> tuple[ExperimentDirective, ...]
The {experiment} directives of a document.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The document.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ExperimentDirective, ...]
|
The directives in document order. |
Source code in src/quivers/dsl/literate/directives.py
woven_body
¶
The body a woven directive holds.
| PARAMETER | DESCRIPTION |
|---|---|
fields
|
The
TYPE:
|
lines
|
The rendered result.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The fields, then the result, one per line. |
Source code in src/quivers/dsl/literate/directives.py
weave_directives
¶
A document with some directives' bodies replaced.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The document.
TYPE:
|
bodies
|
The new body (dedented) of each directive, by its fence's line.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The document with those bodies written in, indented like their fences; every other character is unchanged. |