brel.characteristics.unit_characteristic
This module contains the class for representing xbrl unit characteristics. A unit characteristic associates the aspect Aspect.UNIT with a value. In case of the UnitCharacteristic class, the value is a string.
However, the UnitCharacteristic can also handle more complex units consisting of numerators and denominators.
====================
- author: Robin Schmidiger
- version: 0.2
- date: 07 January 2024
====================
UnitCharacteristic Objects
class UnitCharacteristic(ICharacteristic)
Class for representing an XBRL unit characteristic. A unit characteristic associates the aspect Aspect.UNIT with a value and implements the ICharacteristic interface.
A unit can be identified by its name, which usually indicates how the unit is composed.
Examples: "usd", "sharesPerUSD", "shares"
A unit consists of numerators and denominators, which are lists of QNames.
Most units are simple and consist of a single QName.
You can use the is_simple()
method to check if the unit is simple.
You can get the numerators and denominators of the unit using the get_numerators()
and get_denominators()
methods respectively.
The unit characteristic does have a connection to the concept characteristic. Namely, if the concept characteristic's concept is a monetary concept, the unit's numerators and denominators must be defined in the iso4217 namespace.
get_aspect
def get_aspect() -> Aspect
Returns:
Aspect
: returns Aspect.UNIT
get_numerators
def get_numerators() -> list[QName]
Returns:
list[QName]
: all numerators of the unit
get_denominators
def get_denominators() -> list[QName]
Returns:
list[QName]
: all denominators of the unit
get_value
def get_value() -> str
info: this is different from the numerators/denominators of the unit. It is the name of the unit.
Returns:
str
: the name of the unit
is_simple
def is_simple() -> bool
A unit is simple if it has exactly one numerator and no denominators
Returns:
bool
: True 'IFF' the unit is simple, False otherwise