Signature

The Signature class defines objects that hold a signature associated with a kind of quantity.

Every Signature is associated with a Context, in which a set of base quantities is defined.

Signature objects can be multiplied or divided.

Every Signature object has numerator and denominator members, which hold tuples of elements. Usually, the denominator contains zero values, and the object is said to be in simplified form. However, the denominator can be loaded with non-trivial element values by using the ‘floor division’ operator \\.

The ‘floor division’ operator \\ is an alternative to regular division. When floor division is used, the denominator of the Signature of the right-hand operand is added to the numerator of the left-hand operand and the numerator of the right-hand operand is added to the denominator of the left-hand operand. So, when the right and left-hand arguments have the same signatures, and both are in simplified form, a dimensionless ratio created by \\ retains information about the signatures of the original arguments. Regular division, on the other hand, subtracts the numerator of the right-hand operand from the numerator of the left-hand operand, and similarly for the denominator. So, when the right and left-hand arguments have the same signatures, the numerator and denominator of the resulting Signature will result in only zeros; the result is dimensionless with no information about the signatures of the original arguments.

class Signature(context, numerator, denominator=())

A Signature has a pair of tuples that identify a kind of quantity.

Multiplication and division of signatures adds and subtracts the tuple elements, respectively.

The numerator and denominator of a Signature object are the tuples. This allows the signature of a ‘dimensionless’ quantity to be retained.

A Signature object is in ‘simplified’ form when the denominator is empty (or contains only zeros).

A Signature object may be converted to ‘simplified’ form by setting the numerator to the difference between the numerator and the denominator and setting the exponents in the denominator to zero.

A Signature refers to a Context, which contains a 1-to-1 mapping between signatures and kinds of quantity.

property context

The associated Context

property is_dimensionless

When elements in simplified form are all zero

is_ratio_of(other)

True when the object is a dimensionless ratio and the numerator has the same signature as the``other`` object.

property is_simplified

When elements in the denominator are all zero

simplify()

Return the signature in simplified form.

The numerator returned is the difference between the numerator and the denominator of this object, the elements in the denominator returned are all zero.