Skip to content

Attributes and aliases

Values that belong to members but are not weights, alternative labels, strict matching, and row-wise conversion.

attach_attributes_scale

attach_attributes_scale(
    x: NestedScale,
    attributes: Any,
    source: str | None = None,
    kind: str | None = None,
) -> NestedScale

Append attribute rows. An existing (frame, unit, attribute, source) row is never overwritten: attach a competing value under another source.

scale_attributes

scale_attributes(
    x: NestedScale,
    attribute: str | Sequence[str] | None = None,
    frame: str | None = None,
    source: str | Sequence[str] | None = None,
    inherit: bool = True,
) -> pa.Table

The stored attribute rows, or with frame= one row per member of that frame and attribute, resolved along the hierarchy (origin_frame and origin_unit say where each value was found).

SCALE_ATTRIBUTE_KINDS module-attribute

SCALE_ATTRIBUTE_KINDS = ('property', 'factor')

property = an invertible ratio (lhv, density); factor = one-way (an emission factor, a loss factor).

attach_aliases_scale

attach_aliases_scale(
    x: NestedScale, aliases: Any, source: str | None = None
) -> NestedScale

Append alias rows; an existing (alias, frame, unit, source) row is an error.

scale_aliases

scale_aliases(
    x: NestedScale,
    frame: str | None = None,
    source: str | Sequence[str] | None = None,
) -> pa.Table

The alias rows, optionally of one frame and/or some sources.

scale_match

scale_match(
    x: NestedScale,
    labels: str | Sequence[str],
    frame: str | None = None,
    source: str | Sequence[str] | None = None,
) -> pa.Table

Resolve labels to (frame, unit): exact member names first, then aliases, case-insensitively. method is "exact", "alias", "ambiguous" (with the candidates) or "none".

convert_scale

convert_scale(
    data: Any,
    x: NestedScale,
    attribute: str,
    from_unit: str,
    to_unit: str,
    key: str | None = None,
    frame: str | None = None,
    values: str | Sequence[str] | None = None,
    source: str | Sequence[str] | None = None,
    na_action: str = "error",
    collect: bool | None = None,
) -> Any

Convert the value columns of data from from_unit to to_unit with the attribute resolved for each code. Adds <attribute> (the factor used) and <attribute>.origin_frame (where it was found).