Skip to content

Element

Element(name, element_type, attributes=None, unique_name=None, index=None)

Bases: TM1Object

Abstraction of TM1 Element

Source code in TM1py/Objects/Element.py
def __init__(
    self,
    name,
    element_type: Union[Types, str],
    attributes: List[str] = None,
    unique_name: str = None,
    index: int = None,
):
    self._name = name
    self._unique_name = unique_name
    self._index = index
    self._element_type = None
    self.element_type = element_type
    self._attributes = attributes

ELEMENT_ATTRIBUTES_PREFIX = '}ElementAttributes_' class-attribute instance-attribute

body property

body_as_dict property

element_attributes property

element_type property writable

index property

name property writable

unique_name property

Types

Bases: Enum

CONSOLIDATED = 3 class-attribute instance-attribute

NUMERIC = 1 class-attribute instance-attribute

STRING = 2 class-attribute instance-attribute

__str__()

Source code in TM1py/Objects/Element.py
def __str__(self):
    return self.name.capitalize()

__eq__(other)

Source code in TM1py/Objects/Element.py
def __eq__(self, other: "Element"):
    return all(
        [
            isinstance(other, Element),
            case_and_space_insensitive_equals(self.name, other.name),
            self.element_type == other.element_type,
        ]
    )

__hash__()

Source code in TM1py/Objects/Element.py
def __hash__(self):
    return super().__hash__()

from_dict(element_as_dict) staticmethod

Source code in TM1py/Objects/Element.py
@staticmethod
def from_dict(element_as_dict: Dict) -> "Element":
    return Element(
        name=element_as_dict["Name"],
        unique_name=element_as_dict.get("UniqueName", None),
        index=element_as_dict.get("Index", None),
        element_type=element_as_dict["Type"],
        attributes=element_as_dict.get("Attributes", None),
    )