ConstraintRules#

class superglm.ConstraintRules(rules: tuple[ConstraintSpec, ...] = ())#

Bases: object

An ordered set of fit-time shape rules, built with &.

Examples

>>> from superglm import Constraint
>>> C = Constraint.fit
>>> C.increasing & C.concave & C.cap(0.6, 1.8)
Constraint.fit.increasing & Constraint.fit.concave & Constraint.fit.cap(0.6, 1.8)
validate() → None#

Refuse rule sets that contradict themselves or cannot be fitted.

Stretch ends are not compared here: a numeric end may be a band label of an ordered term, whose order is its declared one. validate_stretches() compares them once the term has placed them on its axis.

validate_stretches() → None#

Refuse reversed stretches and stretches that overlap, once their ends are placed.

A stretch whose end is a band label is skipped: an ordered term compares those in level order before it places them.