Example #1
0
test_tree = [('', 'Neutral'),
             [('a', 'Neutral'),
              [('c', 'Compartment'),
               [('d', 'SpikeGen'),],
               [('e', 'PulseGen'),]]],
             [('b', 'Neutral'), 
              [('f', 'Pool'), 
               [('g', 'Enz'), 
                [('h', 'Pool'),]], 
               [('i', 'Compartment'), ], 
               [('j', 'Nernst')]]]]

def create_tree(tree, parentpath=''):
    if not tree:
        return
    node = tree[0]
    parent = moose.ematrix(parentpath + '/' + node[0], 1, node[1])
    if len(tree) < 2:
        return
    for sub in tree[1:]:
        create_tree(sub, parent.path)

if __name__ == '__main__':
    create_tree(test_tree)
    mu.printtree('/', ignorepaths=[])
    hu.savestate('test_moosestate.h5')


# 
# savestate.py ends here
Example #2
0
             [('a', 'Neutral'),
              [('c', 'Compartment'),
               [('d', 'SpikeGen'),],
               [('e', 'PulseGen'),]]],
             [('b', 'Neutral'), 
              [('f', 'Pool'), 
               [('g', 'Enz'), 
                [('h', 'Pool'),]], 
               [('i', 'Compartment'), ], 
               [('j', 'Nernst')]]]]

def check_tree(tree, parentpath=''):
    if not tree:
        return
    node = tree[0]
    parent = moose.to_el(parentpath + '/' + node[0], 1, node[1])
    if len(tree) < 2:
        return
    for sub in tree[1:]:
        check_tree(sub, parentpath + '/' + node[0])

if __name__ == '__main__':
    hu.restorestate('test_moosestate.h5')
    mu.printtree('/')
    check_tree(test_tree)
    


# 
# restorestate.py ends here