math_spec.operators
The closed set of built-in operators and their call shapes.
One home for each signature: a composition is a macro, and math the language
cannot say is a declared escape:.
BUILTINS = {'sum': Builtin('sum(<expr>), sum(<expr>, over=<dim>) or sum(<expr>, by=<lookup>)', dimension_kwargs=('over',), lookup_kwargs=('by',), at_most_one_of=('over', 'by')), 'at': Builtin('at(<expr>, by=<lookup>)', lookup_kwargs=('by',)), 'sum_back': Builtin("sum_back(<expr>, over=<dim>, within=<n|parameter>[, edge='wrap'][, by=<lookup>])", dimension_kwargs=('over',), lookup_kwargs=('by',), required_value_kwargs=('within',), edge_kwargs=('edge',), optional_kwargs=('by',)), 'shift': Builtin("shift(<expr>, over=<dim>, offset=<n>[, edge='wrap'|<number>][, by=<lookup>])", dimension_kwargs=('over',), lookup_kwargs=('by',), required_value_kwargs=('offset',), edge_kwargs=('edge',), optional_kwargs=('by',)), 'dual': Builtin('dual(<constraint>)')}
module-attribute
#
BUILTIN_NAMES = frozenset(BUILTINS)
module-attribute
#
EDGE_WRAP = 'wrap'
module-attribute
#
Builtin(usage, dimension_kwargs=(), lookup_kwargs=(), at_most_one_of=(), edge_kwargs=(), required_value_kwargs=(), optional_kwargs=())
dataclass
#
The call shape of one built-in operator.
Keyword arguments come in four kinds, and the kind decides what resolution
turns the value into: dimension_kwargs name a dimension
(sum(x, over=generator)); lookup_kwargs name a lookup, which
carries its own dimensions, so it needs no sibling kwarg;
edge_kwargs take a closed keyword or a number;
required_value_kwargs are ordinary values that must be present — a
number, never a name to resolve (shift(..., offset=1)).
Every operator takes one positional argument, the expression; every
dimension or lookup it names arrives in a kwarg value, which is what
lets a macro pass one as a formal. usage is the wording every refusal
quotes back.
at_most_one_of = ()
class-attribute
instance-attribute
#
dimension_kwargs = ()
class-attribute
instance-attribute
#
edge_kwargs = ()
class-attribute
instance-attribute
#
lookup_kwargs = ()
class-attribute
instance-attribute
#
optional_kwargs = ()
class-attribute
instance-attribute
#
required
property
#
Every keyword the call must carry.
required_value_kwargs = ()
class-attribute
instance-attribute
#
usage
instance-attribute
#
kind_of(kwarg)
#
What resolution turns the value of kwarg into: a dimension, a lookup, an edge policy, or a plain value.
Source code in src/math_spec/operators.py
call_shape_error(name, positional, kwargs)
#
Why a call to name does not fit its signature; None if it fits.
Source code in src/math_spec/operators.py
edge_error(name, given)
#
Why an edge= value is not one the language has.
Source code in src/math_spec/operators.py
unknown_operator_message(name)
#
The one wording for "that is not an operator".