M-layer API¶
Functions¶
- expr(v, s, a=no_aspect)¶
Create a new expression
- Parameters
v – the expression value or token
s (
ScaleAspect,Scale) – the scalea (
Aspect, optional) – the aspect
- Returns
- convert(xp, dst)¶
Return a new expression in terms of
dstIf
dstdoes not specify an aspect, the aspect of the initial expression will be carried over.If
dstand the initial expression,xp, each specify an aspect, they must match.- Parameters
xp (
Expression) – the initial expressiondst (
ScaleAspectorScale) – the scale-aspect for the new expression
- Returns
- cast(xp, dst, aspect=no_aspect)¶
Return a new expression in terms of
dstIf
dstdoes not specify an aspect,aspectis used. IfaspectisNone, the aspect ofxpis carried over to the new expression- Parameters
xp (
Expression) – the initial expressiondst (
ScaleAspectorScale) – the scale-aspect for the new expressionaspect (
Aspect, optional) –
- Returns
- token(xp)¶
Return the token or value from an expression
Classes¶
- class Expression(token, mdata)¶
An
Expressionis defined by a token and a scale-aspect pair. The scale-aspect may be a composition of several scale-aspect pairs.- cast(dst, aspect=no_aspect)¶
Return a new M-layer expression
- Parameters
dst (
ScaleAspectorScale) – the scale-aspect pair for the new expressionaspect (
Aspect) –
- Returns
class – ~expression.Expression
Casting determines an aspect for the new expression as follows: i) the aspect as specified in
dst, or, ii) the aspect as specified byaspect, or, iii) the aspect of the initial expression
- convert(dst)¶
Return a new expression in terms of
dst:param dst (
CompoundScaleAspector: :paramCompoundScale: :paramScaleAspector: :paramScale):- Returns
If
dstis aScaleAspect, the associated aspect must match the existing expression.
- property scale_aspect¶
The ScaleAspect of the Expression
- property token¶
The token or value of the Expression
- property value¶
The token or value of the Expression
- class Aspect(aspect_uid)
Aspect objects provide a lightweight wrapper around the unique identifier for an M-layer aspect.
- __eq__(other)
True when both objects have the same uid
- property uid
The M-layer identifier for this aspect
- class Scale(scale_uid)
A Scale encapsulates a unique identifier for an M-layer scale.
- __eq__(other)
True when both objects have the same uids
- property dimension
Return a
Dimensionwhen a scale is associated with a reference in a coherent system of units, like the SI. Otherwise returnNone.
- to_scale_aspect(aspect=no_aspect)
Return a
ScaleAspectcombining this scale andaspect.
- class ScaleAspect(scale, aspect=no_aspect)
A wrapper around a scale and aspect pair.
- __eq__(other)
True when the M-layer identifiers of both objects match
- property uid
A pair of M-layer identifiers for scale and aspect