testable

Contents

testable#

Property-based testing of the axioms with Hypothesis.

An Axiom is an equation stated once on an abstract base class of discopy.abc and inherited by every category below it, where Axiom.failing() and Axiom.inapplicable() classify it when a category breaks it or has no such structure. A Testable category generates its own objects and arrows, and states the laws every type that does so obeys: a term reads back from its representation, its pickle and its tree. The matrix in proptest/ checks every axiom of every category against generated arguments, one cell per pair; CONTRIBUTING.md says how to run it.

Summary#

Equation

An equation is a list of terms to be compared up to a function up_to, the identity by default.

Axiom

An axiom of a category, stated once on an abstract base class and inherited by every category below it.

AxiomFailure

A law declared broken, raised when the bound axiom is called: the reason is the message and equation is the law evaluated on the arguments, whose sides say how it failed.

Testable

A type that comes with a search strategy generating its instances, and the laws every such type obeys: a term reads back from its representation, its pickle and its tree.

Grid

A rectangular grid with composable rows and columns.

ComposablePair

Two morphisms composable from left to right.

ComposableTriple

Three values composable from left to right.

Functions

axiom

Decorate an equation as a categorical axiom: a classmethod of its category, implicitly, whose remaining parameters are generated.

resolve

Resolve the strategy implemented by an annotated type.

substitute

Replace the C0 and C1 type variables of a subspace annotation by the objects and arrows they stand for, rebuilding each parameterised wrapper whose factory the substitution changes.

assert_axioms

Check every axiom of each category on a single generated example, a dry run of the property tests in proptest/.