def test_init_with_neuron_objects(self): n1 = Neuron(name="AVAL") n2 = Neuron(name="PVCR") try: Connection(n1, n2) except Exception: self.fail("Shouldn't fail on Connection init")
def test_same_name_same_id(self): """ Test that two Neuron objects with the same name have the same identifier. Saves us from having too many inserts of the same object. """ c = Neuron(name="boots") c1 = Neuron(name="boots") self.assertEqual(c.identifier, c1.identifier)
def test_adal_connections(): """ See github issue openworm/owmeta#90 """ for x in range(10): adal = Neuron("ADAL") post = Neuron() Connection(pre_cell=adal, post_cell=post) tuple(post.load())
def test_init(self): """Initialization with positional parameters""" c = Connection(Neuron(name='AVAL'), Neuron(name='ADAR'), 3, 'send', 'Serotonin') self.assertIsInstance(c.pre_cell(), Neuron) self.assertIsInstance(c.post_cell(), Neuron) self.assertEqual(c.number(), 3) self.assertEqual(c.syntype(), 'send') self.assertEqual(c.synclass(), 'Serotonin')
def setUp(self): super(ExactNumberMatchTest, self).setUp() fname = p(self.testdir, 'mycsv.csv') text = 'PreCell;PostCell;send;3;neurotransmitter' with open(fname, 'w') as f: f.write(text) self.nt_ds.file_name('mycsv.csv') self.conn_ds.data_context(Connection)(pre_cell=Neuron('PreCell'), post_cell=Neuron('PostCell'), syntype='send', number=3) self.conn_ds.commit()
def test_adal_connections_property(): """ See github issue openworm/owmeta#90 """ for x in range(10): adal = Neuron("ADAL") tuple(adal.connection.get('either'))
def test_load_with_filter(self): # Put the appropriate triples in. Try to load them g = R.ConjunctiveGraph() self.config['rdf.graph'] = g for t in self.trips: g.add(t) c = Connection(pre_cell=Neuron(name="PVCR"), conf=self.config) r = c.load() for x in r: self.assertIsInstance(x, Connection)
def set(self, ob, **kwargs): self.real_neighbor(ob) if isinstance(ob, NeuronClass): ob_name = ob.name() this_name = self.owner.name() for x in ob.member.defined_values: # Get the name for the neighbor try: n = x.name() side = n[n.find(ob_name) + len(ob_name):] name_here = this_name + side this_neuron = Neuron(name_here) self.owner.member(this_neuron) this_neuron.neighbor(x, **kwargs) except ValueError: # XXX: could default to all-to-all semantics print( 'Do not recoginze the membership of this neuron/neuron class', ob) elif isinstance(ob, Neuron): for x in self.owner.member: x.neighbor(ob)
import owmeta from time import time from owmeta.neuron import Neuron owmeta.connect(configFile='owmeta/default.conf') t0 = time() print("Neurons:") print(", ".join(sorted(Neuron().name.get()))) print("Receptors:") print(", ".join(sorted(Neuron().receptor.get()))) tot = time() - t0 print("Took {} seconds".format(tot))
def test_neuron_load(): list(Neuron().load())
def test_neuron_receptors(): for x in range(30): post = Neuron() list(post.receptor())