Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 40 additions & 35 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,36 @@

```
dotnet build # warning-free; warnings are errors
dotnet test # 1379 tests
dotnet test # every test project in the solution
```

`TreatWarningsAsErrors` is on for every project, set in `Directory.Build.props`. It is not
decoration: FS0064 — the unit-of-measure over-constraint warning — is a warning by default, and a
generic function that silently over-constrains its measures still compiles. Turning it into a
build failure is how that class of defect is caught at all. A change that needs a warning
`TreatWarningsAsErrors` is on for every project, set in `Directory.Build.props`, for a reason.
FS0064, the warning for a unit of measure that is over-constrained, is only a warning by default,
and a generic function that silently over-constrains its measures still compiles. Making it a build
failure is the only way that kind of defect gets caught. A change that needs a warning
suppressed needs a comment saying which warning and why.

The library targets `netstandard2.1`; the test project targets `net10.0`.
The library targets `netstandard2.1`, except `Marey.Backend.Gpu` (`net8.0`), `Marey.Verso`
(`net8.0` and `net10.0`), `Marey.Witnesses` (`netstandard2.0`, the compiler service's own target) and
`Marey.Analyzers` (`net10.0`). The test project targets `net10.0`.

## The toolchains the tests shell out to

Programs the library does not ship are driven by the suite, and by two of the packages:

| Program | What it gates |
|---|---|
| `pdflatex` | compiles every golden `.tex` baseline — the only authority on whether emitted TeX is valid |
| `pdftoppm` | rasterises a PDF to check the page is not blank: the compiled TeX one, and since M2.5 the Skia backend's own |
| `pdflatex` | compiles every golden `.tex` baseline, and is the only authority on whether emitted TeX is valid |
| `pdftoppm` | rasterises a PDF to check the page is not blank, both the compiled TeX one and the Skia backend's own |
| `dotnet fsi` | runs every `docs/guide/` snippet, the README's example, every `examples/*.fsx`, and the encoding-block compile checks |
| `ffmpeg` / `ffprobe` | `Marey.Tools.Video` encodes a frame sequence, and the container is read back rather than trusted |
| `latex` / `dvisvgm` | `Marey.Tools.Tex` sets a formula and converts it to outlines. `latex`, not `pdflatex`: dvisvgm reads DVI, and the two ask different questions |

All of them are resolved and run through **`Marey.Toolchain`**. The suite's own are named once in
`tests/Marey.Tests/Tools.fs`; the two packages resolve theirs for themselves, because a consumer
of `Marey.Tools.Video` has no test suite. Add a gate that needs another program by adding it there
rather than by walking `PATH` again — the walk and the `Process` were each written five times
across four files before that module existed, and one of the copies' bugs is described in
`decisions.md` D81.
of `Marey.Tools.Video` has no test suite. A new gate that needs another program goes there too,
rather than walking `PATH` again. Before that module existed, the walk and the `Process` were each
written five times across four files, and one of the copies had a bug of its own.

Each prints a line saying what it found and **passes when the program is absent**, which is right
on a contributor's machine and wrong in CI.
Expand All @@ -44,7 +45,7 @@ PDF, frame and ink gate at once.

### The census, and the switch that makes it enforceable

**Read the test output rather than the green tick**: a local run that skips these has not checked
**Read the test output rather than the green tick.** A local run that skips these has not checked
the TikZ backend, the raster one, the guide or the examples at all.

Reading is a thing a person does once and then stops doing, so it is mechanised.
Expand All @@ -70,16 +71,17 @@ The package list and the reason for each entry are in `.github/tex-packages.txt`

## Golden baselines

57 baselines, in SVG *and* `tikzpicture` source, tracked under `tests/Marey.Tests/golden/`. They
are text and are meant to be reviewed as a diff — that is why both formats were chosen.
The baselines are tracked under `tests/Marey.Tests/golden/`, 40 in SVG and 42 in `tikzpicture`
source. They
are text, meant to be reviewed as a diff, which is why both formats were chosen.

There are exactly two binary baselines, and each is the sidecar half of a pair: a `.tex` names a
file and the `.png` is that file, so the two only mean anything together. `figure-image.png` is a
hand-written pixel array; `figure-field-lic.png` is a line-integral convolution computed from a
stated seed with nothing but IEEE arithmetic. Both are written by Marey's own zero-dependency PNG
encoder, so nothing outside the repository can move them. **There is no PNG baseline of a rendered figure**,
and there will not be: a bitmap is not reviewable in a diff and would break on a Skia version
bump for reasons unrelated to Marey. The raster backend is covered by structure, determinism and
encoder, so nothing outside the repository can move them. **There is no PNG baseline of a rendered
figure**, and there will not be one, because a bitmap cannot be reviewed in a diff and would break
on a Skia version bump for reasons unrelated to Marey. The raster backend is covered by structure, determinism and
ink instead.

A failing golden writes the candidate output next to the baseline and names both paths. If the new
Expand All @@ -93,7 +95,7 @@ Accepting a baseline is a reviewable act. A pull request that moves a baseline s
description what changed in the picture and why, because the diff shows what changed in the file
and those are not the same question.

`tests/Marey.Tests/README.md` documents the suite in full — the property generators, the tolerance
`tests/Marey.Tests/README.md` documents the suite in full: the property generators, the tolerance
policy, the determinism checks and the seed sweep. Read it before adding tests.

## The public API listing
Expand All @@ -114,26 +116,28 @@ the picture.
Four constraints hold across the whole tree, and a change that breaks one needs to argue for it
rather than work around it:

- **`Marey.Core` takes no dependencies.** Not a package, not a backend, nothing. Nor do
`Marey.Units`, `Marey.Plot`, `Marey.Backend.Svg` or `Marey.Backend.Tikz`. `Marey.Backend.Skia`
is the one package in the solution with a third-party reference, which is why it is a separate
package, and a test asserts the other five against the built assembly graph rather than
against the project files.
- **`Marey.Plot` references no backend.** Rendering enters as a function — this is why
- **`Marey.Core` takes no dependencies at all.** Nor do `Marey.Units`, `Marey.Plot`,
`Marey.Backend.Svg` or `Marey.Backend.Tikz`. A third-party reference goes in a package of its
own, outside the `Marey` metapackage: SkiaSharp in `Marey.Backend.Skia`, Silk.NET in
`Marey.Backend.Gpu`, Fable.Core in `Marey.Backend.Web`, `Verso.Abstractions` in `Marey.Verso`,
and the compiler service and the analyzers SDK in `Marey.Witnesses` and `Marey.Analyzers`. A
test checks the five above, with `Marey.Anim` and `Marey.Toolchain`, against the built assembly
graph rather than against the project files.
- **`Marey.Plot` references no backend.** Rendering enters as a function, which is why
`Chart.toSvg` takes a renderer rather than importing one, and why `Frames.render` takes one too.
It does reference `Marey.Anim`, and that edge was argued rather than assumed: the storyboard
block names an `Anim` and a `Figure` in one signature, `Marey.Anim` is 36 KB with no
dependencies of its own, and the other direction would put the whole plotting stack behind
`Anim.tween`.
- **`Marey.Core` and `Marey.Anim` stay Fable-compatible.** Both `.fsproj` files say so, and it is
why the frame writer is in `Marey.Plot` despite naming nothing above `Anim<Node>`: `System.IO`
and `Array.Parallel` do not belong in either. A change that puts a concurrency primitive or a
- **`Marey.Core` and `Marey.Anim` stay Fable-compatible.** Both `.fsproj` files say so. The frame writer
is in `Marey.Plot` for that reason, although it names nothing above `Anim<Node>`, since
`System.IO` and `Array.Parallel` belong in neither. A change that puts a concurrency primitive or a
file handle in one of those two has broken something the packages promise.
- **The scene IR has ten cases and gains none casually.** Axes, legends, error bars and bars are
*compiled into* `Path`/`Text`/`Markers` by the layer above. A new node variant is a cost against
every backend — the tenth, `Opacity`, was added in M3 because fading a composited group cannot
be expressed by multiplying alpha through a subtree, and it broke every backend at compile time
on the way in. That is the intended cost.
*compiled into* `Path`/`Text`/`Markers` by the layer above. Every backend pays for a new node
variant. The tenth, `Opacity`, was added because fading a composited group cannot be expressed
by multiplying alpha through a subtree, and it broke every backend at compile time on the way
in, which is the intended cost.

Comments throughout the source and tests cite decision numbers (`D18`, `D41`). They refer to the
project's implementation decision log, which is kept outside this repository; the numbers are
Expand All @@ -149,7 +153,8 @@ not touched by any of this.

## Pull requests

- Branch from `main` and open the pull request against it. CI runs on every pull request and on `main`.
- Branch from `main` and open the pull request against it. CI runs on every pull request and on
`main`.
- `dotnet build` warning-free and `dotnet test` green before review.
- One logical change per pull request. A baseline move, a new geom and a refactor are three.
- New public API needs a runnable example. Every example in `docs/guide/` and `examples/` is
Expand All @@ -161,5 +166,5 @@ not touched by any of this.
## Reporting a defect

A figure that renders wrongly is best reported as the shortest F# script that produces it, plus
the output. If it involves units, include the witnesses — most surprising axis labels are a
question about which unit was passed rather than about the axis compiler.
the output. If it involves units, include the witnesses, because most surprising axis labels
turn out to be a question about which unit was passed rather than about the axis compiler.
3 changes: 2 additions & 1 deletion NUGET.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ others are separate references.
| `Marey.Verso` | The Verso notebook extension, loaded by `#!extension Marey.Verso`. |
| `Marey.Analyzers`, `Marey.Witnesses` | Fixes for a call missing the right unit witness: F# analyzers for Ionide and the CLI, and the same fixes over the compiler service. Not in `Marey`. |

1.0.0: the compatibility page says what a version number promises from here on. MIT licensed.
Marey is at 1.0.0, and the compatibility page says what a version number promises from here on.
MIT licensed.

- [The guide](https://axym-labs.github.io/marey/guide/)
- [Gallery](https://axym-labs.github.io/marey/gallery.html)
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@ dotnet test
```

The suite holds property tests for the dimension algebra, the scales, ticks, interpolation, colour
and the scene; golden baselines in SVG and `tikzpicture` source; a `pdflatex` compile; ink checks
over the compiled TeX, the PNG and the PDF; the guide, the README and the examples run; and the
same baselines drawn under Fable and Node. Gates that need an external program report it absent
rather than fail, and `MAREY_REQUIRE_TOOLCHAIN=1`, which CI sets, makes an absent one a failure.
and the scene, and golden baselines in SVG and `tikzpicture` source. It compiles the TeX with
`pdflatex`, checks for ink in the compiled TeX, the PNG and the PDF, runs the guide, the README and
the examples, and draws the same baselines under Fable and Node. A gate that needs an external
program reports it absent rather than failing. CI sets `MAREY_REQUIRE_TOOLCHAIN=1`, which makes an
absent program a failure.

## Status

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/06-paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ grid as the journal's box.

**Panels.** `a |> Chart.above b` puts `a` over `b`, and `a |> Chart.beside b` puts `b` to the right
of `a`. Both take figures of any shape, so a panel beside a stack of two runs the height of both.
The panels are one grid: the room each needs for its ticks, titles, legend and colorbar is made the
same along each grid line, so plots in a column share their left and right edges and plots in a
The panels form one grid. The room each needs for its ticks, titles, legend and colorbar is made
the same along each grid line, so plots in a column share their left and right edges and plots in a
row their top and bottom. A layout that does not nest is drawn as a picture,
`Chart.mosaic "AAB;DEB;DCC" [ 'A', …; 'B', … ]`, each character a cell and `.` an empty one.

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/10-storyboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ and `fadeIn` fades a named part in.
**`points.[10]`** names the eleventh datum. A scatter of 100 000 points is one node, so naming one
splits it into the marks before, the mark, and the marks after; nothing is split until something is
named. When rows have names of their own, `key` in the `plot` block keys each mark by its row's
name, so a morph between two tables pairs rows by name: the rows that stayed hold still, a removed
name, so a morph between two tables pairs rows by name. The rows that stayed hold still, a removed
row fades out where it was, and `points.["S6"]` names a row by its key.

## Filmed
Expand Down
8 changes: 4 additions & 4 deletions docs/guide/11-notebooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ samples 48 frames, about half a megabyte; `Html.filmAt n` takes another budget.
encoder, so it plays wherever the notebook renders.

**A large figure is drawn on a canvas.** From 5000 drawn elements on, `Html.CanvasThreshold`, the
cell holds a canvas and the scene goes to it as bytes rather than SVG: a scatter of 10⁵ points is
2.1 MB rather than 6.4 MB and draws in tens of milliseconds. The bytes carry the kernel's text
measurements, so the labels sit where they would in the SVG, and under the canvas is the figure's
SVG without its large batches, so a viewer that runs no script still shows the axes, titles and
cell holds a canvas and the scene goes to it as bytes rather than SVG. A scatter of 10⁵ points is
then 2.1 MB rather than 6.4 MB and draws in tens of milliseconds. The bytes carry the kernel's text
measurements, so the labels sit where they would in the SVG. Under the canvas is the figure's SVG
without its large batches, so a viewer that runs no script still shows the axes, titles and
legend. `Html.renderMode` chooses `RenderMode.Svg`, `Canvas` or `Auto`, the default.

**A saved notebook** keeps each figure as it was drawn, a live one at the state the reader left it
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/12-interaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ explorer
In Verso, `explorer` as a cell's value is the live figure: drag the slider and the section is
recomputed for that drive. On the figure, a drag zooms onto a box (on a polar panel, onto the
sector around it, drawn at its own angles), shift-drag pans, a double-click returns to the view's
own domains, and the pointer's position is read out in the axes' units. The
page formats no number; every label and reading is written by the kernel.
own domains, and the pointer's position is read out in the axes' units. The page formats no
number; every label and reading is written by the kernel.

## A live figure is a value

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/13-gpu-window-browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ and agree with the CPU's steps to a few parts in a million.
same for a live figure, with its controls in a strip above it. Drag to zoom, shift-drag to pan,
double-click to reset, hover to read, Tab and the arrows for the controls, Escape to close. The
window's pointer and keys become the messages a notebook page sends for the same gestures, stepped
by `Live.step`, so a session in a window reaches the states a notebook session would, and a
by `Live.step`. A session in a window therefore reaches the states a notebook session would, and a
recording made in one replays in the other.

```fsharp norun
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/16-uncertainty.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ scatter about the line as their uncertainties say they should. g = `9.808(19) m

`Fit.line` weights each point by its uncertainty, and with uncertain lengths too by their effective
variance. Its slope and intercept are `Uncertain` values whose contributions point back to every
input of every point, so g's budget names them: the two end lengths' timings carry most of it, as
input of every point, so g's budget names them. The two end lengths' timings carry most of it, as
the ends of a line hold its slope, and the stopwatch is one row, not five. 4π²/slope composes its
unit as s⁻²·m; `Uncertain.convert` restates it in the witness one would write.

Expand Down Expand Up @@ -166,7 +166,7 @@ printfn "%s" (MonteCarlo.report releaseCheck)

The law of propagation gives h = 1.0(1.2) mm, and a 95 % interval from −1.26 to 3.26 mm, below
the bob's lowest point. `MonteCarlo.check` draws every input from its distribution, evaluates the
model for each draw and compares the two intervals as JCGM 101 does: here they differ by 1.26 mm
model for each draw and compares the two intervals as JCGM 101 does. Here they differ by 1.26 mm
against a tolerance of 0.05, and the check says to report the Monte Carlo interval, 0 to 3.79 mm.
It runs in batches until the comparison is settled, 2 × 10⁴ trials here.

Expand Down
Loading
Loading