Specification

Labs

class Specification

Description

Structure containing dimensions of a unit or quantity.

Note that multiple quantities and units may have the same dimensions, yet be treated as different types. This provides the distinction, e.g. width is not height.

Format specification is: - :n - print specification name, if it has one - :e - print specification expression, if it has one - :d - print specification dimensions

By default, each mode will be tested in order until one succeeds.

Warning

Unnamed quantities are not fully supported yet.

Inheritance:

Members defined in Specification (13 members)

dimensions

R

Exact exponents of each nonzero dimension.

expression

R

The expression use to derive this quantity specification.

is_base

R

Whether this specification is the root of its hierarchy, i.e. a named specification without a parent.

kind

R

The root specification this is part of.

name

R

Name given to this quantity specification, e.g. length, width.

owned_expression

R

The expression owned by this specification.

parent

R

The immediate parent specification if this is a child specification.

__hash__

__str__

common_with

Try and find a specification common to both left and right.

convertible_from

Whether other can be assigned to a quantity specified by this.

dimensionless

A dimensionless quantity specification.

find_or_create

Find or create a base quantity specification with a single dimension.

Attributes

property dimensions: syside.BufferView[tuple[syside.experimental.units.BaseDimension, fractions.Fraction]]

Exact exponents of each nonzero dimension.

property expression: syside.BufferView[tuple[syside.experimental.units.Specification, fractions.Fraction]]

The expression use to derive this quantity specification.

property is_base: bool

Whether this specification is the root of its hierarchy, i.e. a named specification without a parent.

property kind: syside.experimental.units.Kind

The root specification this is part of.

property name: str | None

Name given to this quantity specification, e.g. length, width.

None if this was derived from an expression.

property owned_expression: syside.BufferView[tuple[syside.experimental.units.Specification, fractions.Fraction]]

The expression owned by this specification.

May be empty if one is inherited, and not overridden.

property parent: syside.experimental.units.Specification | None

The immediate parent specification if this is a child specification.

Methods

__hash__() → int
__str__() → str
common_with(arg: syside.experimental.units.Specification, /) → syside.experimental.units.Specification | None

Try and find a specification common to both left and right.

If kinds are different, none is returned.

common_with(arg: syside.experimental.units.Kind, /) → syside.experimental.units.Specification | None

Try to find a specification common with other.

If kinds are different, none is returned, otherwise this, i.e. common type is promoted from kind, rather than demoted to a common kind.

convertible_from(arg: syside.experimental.units.Specification, /) → syside.experimental.units.Convertible
convertible_from(arg: syside.experimental.units.Kind, /) → syside.experimental.units.Convertible

Whether other can be assigned to a quantity specified by this.

static dimensionless() → syside.experimental.units.Specification

A dimensionless quantity specification.

static find_or_create(name: str, dimension: syside.experimental.units.BaseDimension) → syside.experimental.units.Specification

Find or create a base quantity specification with a single dimension.

Note that these specifications can never be non-negative, and are always real scalar.

static find_or_create(name: str, expression: Sequence[tuple[syside.experimental.units.Specification, fractions.Fraction | int]], is_kind: bool = False) → syside.experimental.units.Specification

Find or create a derived quantity with an expression.

The given expression may be sorted and deduplicated before searching. Duplicate entries may be discarded.

static find_or_create(name: str, parent: syside.experimental.units.Specification, expression: Sequence[tuple[syside.experimental.units.Specification, fractions.Fraction | int]], is_kind: bool = False) → syside.experimental.units.Specification

Find or create a direct child quantity with a custom expression.

The given expression may be sorted and deduplicated before searching. Duplicate entries may be discarded.

static find_or_create(name: str, parent: syside.experimental.units.Specification, is_kind: bool = False) → syside.experimental.units.Specification

Find or create a direct child quantity.