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 scale

  • a (Aspect, optional) – the aspect

Returns

Expression

convert(xp, dst)

Return a new expression in terms of dst

If dst does not specify an aspect, the aspect of the initial expression will be carried over.

If dst and the initial expression, xp, each specify an aspect, they must match.

Parameters
Returns

Expression

cast(xp, dst, aspect=no_aspect)

Return a new expression in terms of dst

If dst does not specify an aspect, aspect is used. If aspect is None, the aspect of xp is carried over to the new expression

Parameters
Returns

Expression

token(xp)

Return the token or value from an expression

value(xp)

An alias for token() that returns the value of an expression

Classes

class Expression(token, mdata)

An Expression is 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
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 by aspect, or, iii) the aspect of the initial expression

convert(dst)

Return a new expression in terms of dst

:param dst (CompoundScaleAspect or: :param CompoundScale: :param ScaleAspect or: :param Scale):

Returns

Expression

If dst is a ScaleAspect, 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 Dimension when a scale is associated with a reference in a coherent system of units, like the SI. Otherwise return None.

to_scale_aspect(aspect=no_aspect)

Return a ScaleAspect combining this scale and aspect.

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