コード例 #1
0
ファイル: test_util.py プロジェクト: nsdf/nsdf
 def test_add_children(self):
     names = ['test_{}'.format(str(ii)) for ii in range(10)]
     comps = [model.ModelComponent(name) for name in names]
     self.root.add_children(comps)
     self.assertEqual(len(self.root.children), len(comps))
     for comp in comps:
         self.assertEqual(comp.parent, self.root)
コード例 #2
0
ファイル: test_util.py プロジェクト: nsdf/nsdf
 def test_add_child(self):
     name = 'test'
     uid = '123'
     comp = model.ModelComponent(name, uid)
     self.assertEqual(comp.name, name)
     self.assertEqual(comp.uid, uid)
     self.root.add_child(comp)
     self.assertEqual(len(self.root.children), 1)
     self.assertEqual(self.root.children[name], comp)
     self.assertEqual(comp.parent, self.root)
コード例 #3
0
ファイル: test_util.py プロジェクト: nsdf/nsdf
 def setUp(self):
     self.root = model.ModelComponent('root', '1')
コード例 #4
0
ファイル: util.py プロジェクト: nsdf/nsdf
def create_ob_model_tree():
    """This creates a model tree of the structure:

        /model
        |
        |__Granule
        |       |
        |       |__granule_0
        |       |       |__gc_0
        |       |       |__...
        |       |       |__gc_19
         ... ... ...
        |       |
        |       |__granule_9
        |               |__gc_0
        |               |__...
        |               |__gc_19 
        |__Mitral
        |       |
        |       |__mitral_0
        |       |       |__mc_0
        |       |       |__...
        |       |       |__mc_14
         ... ... ...
        |       |
        |       |__mitral_9
        |               |__mc_0
        |               |__...
        |               |__mc_19
       

        """
    uid = 0
    model_tree = model.ModelComponent('model', uid=getuid())
    granule = model.ModelComponent('Granule', uid=getuid(), parent=model_tree)
    mitral = model.ModelComponent('Mitral', uid=getuid(), parent=model_tree)
    granule_cells = [
        model.ModelComponent('granule_{}'.format(ii),
                             uid=getuid(),
                             parent=granule) for ii in range(10)
    ]
    mitral_cells = [
        model.ModelComponent('mitral_{}'.format(ii),
                             uid=getuid(),
                             parent=mitral) for ii in range(10)
    ]
    for cell in granule_cells:
        cell.add_children([
            model.ModelComponent('gc_{}'.format(ii), uid=getuid())
            for ii in range(20)
        ])
    for cell in mitral_cells:
        cell.add_children([
            model.ModelComponent('mc_{}'.format(ii), uid=getuid())
            for ii in range(15)
        ])
    reset_uid()
    return {
        'model_tree': model_tree,
        'granule_population': granule,
        'mitral_population': mitral,
        'granule_cells': granule_cells,
        'mitral_cells': mitral_cells,
        'cells': granule_cells + mitral_cells
    }