Quantity

class Quantity(*args, **kwargs)[source]

Bases: DeepDataValue

Quantity.

Parameters:
  • amount – Amount.

  • unit – Unit.

  • lower_bound – Lower bound.

  • upper_bound – Upper bound.

datatype_class

alias of QuantityDatatype

datatype: ClassVar[QuantityDatatype] = QuantityDatatype()

Datatype associated with this value class.

template_class

alias of QuantityTemplate

variable_class

alias of QuantityVariable

classmethod check(arg: Any, function: Callable[[...], Any] | str | None = None, name: str | None = None, position: int | None = None) Self[source]

Coerces arg into an instance of this class.

If arg cannot be coerced, raises an error.

Parameters:
  • arg – Value.

  • function – Function or function name.

  • name – Argument name.

  • position – Argument position.

Returns:

Object.

__init__(amount: VTQuantityContent, unit: VTItem | None = None, lower_bound: VTQuantityContent | None = None, upper_bound: VTQuantityContent | None = None)[source]
property amount: Decimal

The amount of quantity.

get_amount() Decimal[source]

Gets the amount of quantity.

Returns:

Amount.

property unit: Item | None

The unit of quantity.

get_unit(default: Item | None = None) Item | None[source]

Gets the unit of quantity.

If the unit is None, returns default.

Parameters:

default – Default unit.

Returns:

Unit.

property lower_bound: Decimal | None

The lower bound of quantity.

get_lower_bound(default: Decimal | None = None) Decimal | None[source]

Gets the lower bound of quantity.

If the lower bound is None, returns default.

Parameters:

default – Default lower bound.

Returns:

Lower bound.

property upper_bound: Decimal | None

The upper bound of quantity.

get_upper_bound(default: Decimal | None = None) Decimal | None[source]

Gets the upper bound of quantity.

If the upper bound is None, returns default.

Parameters:

default – Default upper bound.

Returns:

Upper bound.

class QuantityTemplate(*args, **kwargs)[source]

Bases: DeepDataValueTemplate

Quantity template.

Parameters:
  • amount – Amount or quantity variable.

  • unit – Unit, item template, or item variable.

  • lower_bound – Lower bound or quantity variable.

  • upper_bound – Upper bound or quantity variable.

object_class

alias of Quantity

__init__(amount: VTQuantityContent, unit: VTItem | None = None, lower_bound: VTQuantityContent | None = None, upper_bound: VTQuantityContent | None = None) None[source]
property amount: QuantityVariable | Decimal

The amount of quantity template.

get_amount() QuantityVariable | Decimal[source]

Gets the amount of quantity template

Returns:

Amount or quantity variable.

property unit: ItemTemplate | ItemVariable | Item | None

The unit of quantity template.

get_unit(default: ItemTemplate | ItemVariable | Item | None = None) ItemTemplate | ItemVariable | Item | None[source]

Gets the unit of quantity template

If the unit is None, returns default.

Parameters:

default – Default unit.

Returns:

Unit, item template, or item variable.

property lower_bound: QuantityVariable | Decimal | None

The lower bound of quantity template.

get_lower_bound(default: QuantityVariable | Decimal | None = None) QuantityVariable | Decimal | None[source]

Gets the lower bound of quantity template

If the lower bound is None, returns default.

Parameters:

default – Default lower bound.

Returns:

Lower bound or quantity variable.

property upper_bound: QuantityVariable | Decimal | None

The upper bound of quantity template.

get_upper_bound(default: QuantityVariable | Decimal | None = None) QuantityVariable | Decimal | None[source]

Gets the upper bound of quantity template.

If the upper bound is None, returns default.

Parameters:

default – Default upper bound.

Returns:

Upper bound or quantity variable.

class QuantityVariable(name: str, variable_class: type[Variable] | type[Term] | None = None)[source]

Bases: DeepDataValueVariable

Quantity variable.

Parameters:

name – Name.

object_class

alias of Quantity