lifecycles.LifeCycle.get_attributes

LifeCycle.get_attributes(attr_name, of=None) dict

retrieve the temporal attributes of the LifeCycle

Parameters:
  • attr_name – the name of the attribute

  • of – the element for which to retrieve the attributes. If None, all attributes are returned

Returns:

a dictionary keyed by element id and valued by a dictionary keyed by temporal id and valued by the attribute value

Example:

>>> lc = LifeCycle()
>>> lc.add_partition([[1,2], [3,4,5]])
>>> lc.add_partition([[1,2,3], [4,5]])
>>> attributes = {
>>>     1: {0: 'red', 1: 'blue'}, # element 1 is red at time 0 and blue at time 1
>>>     2: {0: 'green', 1: 'magenta'} # element 2 is green at time 0 and magenta at time 1
>>> }
>>> lc.set_attributes(attributes, attr_name="color")
>>> lc.get_attributes("color")
>>> # {1: {0: 'red', 1: 'blue'}, 2: {0: 'green', 1: 'magenta'}}
>>> lc.get_attributes("color", of=1) # get the attributes of element 1
>>> # {0: 'red', 1: 'blue'}