Table Of Contents

Previous topic

handler.py

Next topic

linkage.py

This Page

ind2id.py

class Ind2Id(object):

Object id handler for data matrix.

def __init__(self):

Initialize an id handler.

>>> from simo.matrix.ind2id import Ind2Id
>>> ii = Ind2Id()
>>> ii.ids
defaultdict(<type 'dict'>, {})

def add_id(self, iteration, branch, level, ind, obj_id, parlev=None, parind=None):

Add id for a new object:

>>> ii.add_id(0, 0, 0, 0, ('SIMULATION', 'SIMULATION'))
>>> dict(ii.ids)
{(0, 0): {(0, 0): ('SIMULATION', 'SIMULATION')}}
>>> dict(ii.inds)
{(0, 0): {(0, 'SIMULATION'): 0}}
>>> ii.add_id(0, 0, 1, 0, ('UID000', 'UID000'))
>>> ii.ids[(0, 0)][(1, 0)]
('UID000', 'UID000')
>>> ii.add_id(0, 0, 1, 1, ('UID001', 'UID001'))
>>> ii.ids[(0, 0)][(1, 1)]
('UID001', 'UID001')
>>> ii.add_id(0, 0, 1, 2, ('UID002', 'UID002'))
>>> ii.ids[(0, 0)][(1, 2)]
('UID002', 'UID002')
>>> ii.add_id(0, 0, 2, 0, (None, None), 1, 0)
>>> ii.ids[(0, 0)][(2, 0)]
('UID000-0', 'UID000-0')
>>> ii.add_id(0, 0, 2, 1, (None, None), 1, 1)
>>> ii.ids[(0, 0)][(2, 1)]
('UID001-0', 'UID001-0')
>>> ii.add_id(0, 0, 2, 2, (None, None), 1, 1)
>>> ii.add_id(0, 0, 3, 0, (None, None), 2, 2)
>>> ii.ids[(0, 0)][(3, 0)]
('UID001-1-0', 'UID001-1-0')
>>> ii.inds[(0, 0)][(3, 'UID001-1-0')]
0
>>> ii.inds[(0, 0)][(2, 'UID001-1')]
2

def get_id(self, iteration, branch, level, oind):

Get object id:

>>> ii.get_id(0, 0, 1, 0)
('UID000', 'UID000')
>>> ii.get_id(0, 0, 1, 1)
('UID001', 'UID001')
>>> ii.get_id(0, 0, 2, 1)
('UID001-0', 'UID001-0')

def get_ind(self, iteration, branch, level, oid):

Get object index:

>>> ii.get_ind(0, 0, 1, 'UID000')
0

def remove_id(self, iteration, branch, level, oind):

>>> ii.remove_id(0, 0, 1, 0)
>>> ii.get_id(0, 0, 1, 0)
>>> ii.get_ind(0, 0, 1, 0)