hmf.core.domain

Model domains and the domain policy (issue #390).

Each model will carry two domains, as class variables:

valid_domain

Where the model’s formula is mathematically defined or sensible (e.g. sigma > 0). Outside it, evaluation always raises.

calibration_domain

Where the model was calibrated against simulations. Outside it, results are extrapolations, handled according to the user’s DomainPolicy.

This module provides the Domain type describing either, and apply_domain_policy(), which applies a policy to a result.

Bounds are given in the canonical units of hmf.core.units.CANONICAL_UNITS. A bound on a dimensional variable is a Quantity; the values checked against it must then be Quantities too.

Classes

Domain(bounds[, source])

A region of the space of a model's input variables: one interval per variable.

Interval(lower, upper[, unit])

A closed interval [lower, upper] of one variable.

Functions

apply_domain_policy(result, inside, policy, *)

Apply a domain policy to a result computed (partly) outside a domain.

Exceptions

DomainError

Inputs are outside a model's domain, and the policy forbids that.