def get_component(): # Create a model, composed of an iaf neuron, and iaf_2coba_model = ComponentClass( name="iaf_1coba", subnodes={"iaf": iaf.get_component(), "cobaExcit": coba_synapse.get_component()}) # Connections have to be setup as strings, because we are deep-copying objects. iaf_2coba_model.connect_ports("iaf.V", "cobaExcit.V") iaf_2coba_model.connect_ports("cobaExcit.I", "iaf.ISyn") return iaf_2coba_model
def get_component(): # Create a model, composed of an iaf neuron, and iaf_2coba_model = ComponentClass(name="iaf_1coba", subnodes={ "iaf": iaf.get_component(), "cobaExcit": coba_synapse.get_component() }) # Connections have to be setup as strings, because we are deep-copying objects. iaf_2coba_model.connect_ports("iaf.V", "cobaExcit.V") iaf_2coba_model.connect_ports("cobaExcit.I", "iaf.ISyn") return iaf_2coba_model
def get_component(): # Create a model, composed of an iaf neuron, and iaf_nmda_model = ComponentClass( name="iaf_2coba", subnodes={"iaf": iaf.get_component(), "nmda": nmda.get_component(), 'cobaExcit': coba_synapse.get_component() }) iaf_nmda_model.connect_ports("iaf.V", "cobaExcit.V") iaf_nmda_model.connect_ports("iaf.V", "nmda.V") iaf_nmda_model.connect_ports("cobaExcit.I", "iaf.ISyn") iaf_nmda_model.connect_ports("nmda.I", "iaf.ISyn") return iaf_nmda_model
def test_connect_ports(self): # Signature: name(self, src, sink) # Connects the ports of 2 subcomponents. # # The ports can be specified as ``string`` s or ``NamespaceAddresses`` es. # # # :param src: The source port of one sub-component; this should either an # event port or analog port, but it *must* be a send port. # # :param sink: The sink port of one sub-component; this should either an # event port or analog port, but it *must* be either a 'recv' or a # 'reduce' port. tIaf = TestableComponent('iaf') tCoba = TestableComponent('coba_synapse') # Should be fine: c = ComponentClass(name='C1', subnodes={'iaf': tIaf(), 'coba': tCoba()}) c.connect_ports('iaf.V', 'coba.V') c = ComponentClass(name='C1', subnodes={'iaf': tIaf(), 'coba': tCoba()}, portconnections=[('iaf.V', 'coba.V')] ) # Non existant Ports: c = ComponentClass(name='C1', subnodes={'iaf': tIaf(), 'coba': tCoba()}) self.assertRaises( NineMLRuntimeError, c.connect_ports, 'iaf.V1', 'coba.V') self.assertRaises( NineMLRuntimeError, c.connect_ports, 'iaf.V', 'coba.V1') self.assertRaises( NineMLRuntimeError, ComponentClass, name='C1', subnodes={'iaf': tIaf(), 'coba': tCoba()}, portconnections=[('iaf.V1', 'coba.V')] ) self.assertRaises( NineMLRuntimeError, ComponentClass, name='C1', subnodes={'iaf': tIaf(), 'coba': tCoba()}, portconnections=[('iaf.V', 'coba.V1')] ) # Connect ports the wronf way around: # [Check the wright way around works:] c = ComponentClass(name='C1', subnodes={'iaf': tIaf(), 'coba': tCoba()}, portconnections=[('coba.I', 'iaf.ISyn')] ) # And the wrong way around: c = ComponentClass(name='C1', subnodes={'iaf': tIaf(), 'coba': tCoba()}) self.assertRaises( NineMLRuntimeError, c.connect_ports, 'iaf.ISyn.', 'coba.I') self.assertRaises( NineMLRuntimeError, c.connect_ports, 'coba.V', 'iaf.V') # Error raised on duplicate port-connection: c = ComponentClass(name='C1', subnodes={'iaf': tIaf(), 'coba': tCoba()}, ) c.connect_ports('coba.I', 'iaf.ISyn') self.assertRaises( NineMLRuntimeError, c.connect_ports, 'coba.I', 'iaf.ISyn')