Exemple #1
0
 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 make_syn():
     import struct
     u = struct.pack("=2f", random.random(), random.random())
     z = struct.pack("=2f", random.random(), random.random())
     a = Neuron(u.encode('hex'))
     b = Neuron(z.encode('hex'))
     v.value(a.neighbor(b))
     return (a, b)
Exemple #3
0
 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')
Exemple #4
0
 def make_syn():
     import struct
     u = struct.pack("=2f", random.random(), random.random())
     z = struct.pack("=2f", random.random(), random.random())
     a = Neuron(u.encode('hex'))
     b = Neuron(z.encode('hex'))
     v.value(a.neighbor(b))
     return (a, b)
Exemple #5
0
 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)
Exemple #6
0
def test_adal_connections():
    """
    See github issue openworm/PyOpenWorm#90
    """
    for x in range(10):
        adal = Neuron("ADAL")
        post = Neuron()
        Connection(pre_cell=adal, post_cell=post)
        tuple(post.load())
Exemple #7
0
 def test_1(self):
     import bibtex
     bt = bibtex.parse("my.bib")
     n1 = Neuron("AVAL")
     n2 = Neuron("DA3")
     c = Connection(pre_cell=n1, post_cell=n2, synclass="synapse")
     e = Evidence(bibtex=bt['white86'])
     e.asserts(c)
     print(list(e.load()))
Exemple #8
0
    def test_get_evidence(self):
        # Reference two neurons
        n1 = Neuron(name='AVAL')
        n2 = Neuron(name='PVCR')

        # Declare a connection between them
        c = Connection(n1, n2, number=1)
        e = Evidence()
        # Create an Evidence search-object
        e.asserts(c)

        # look for all of the evidence for the connection 'c'
        for x in e.load():
            print(x.author())
Exemple #9
0
def test_adal_connections_property():
    """
    See github issue openworm/PyOpenWorm#90
    """
    for x in range(10):
        adal = Neuron("ADAL")
        tuple(adal.connection.get('either'))
Exemple #10
0
    def test_2(self):
        # Reference two neurons
        n1 = Neuron(name='AVAL')
        n2 = Neuron(name='PVCR')

        # Declare a connection between them
        c = Connection(n1, n2, number=1)
        c_id = c.identifier
        # Attach some evidence for the connection
        e = Evidence(author="Danny Glover")
        e.asserts(c)
        # look at what else this evidence has stated
        e.save()
        e = Evidence(author="Danny Glover")
        r = e.asserts()
        ids = set(x.identifier for x in r)
        self.assertIn(c_id, ids)
Exemple #11
0
 def test_load_with_filter(self):
     # Put the appropriate triples in. Try to load them
     g = R.Graph()
     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)
Exemple #12
0
def test_neuron_load():
    list(Neuron().load())
Exemple #13
0
def test_neuron_receptors():
    for x in range(30):
        post = Neuron()
        list(post.receptor())
Exemple #14
0
import PyOpenWorm as POW
from PyOpenWorm.worm import Worm
from PyOpenWorm.neuron import Neuron
from PyOpenWorm.network import Network
import OpenWormData as OWD

if __name__ == "__main__":
    with POW.connect('default.conf') as conn:
        ctx = POW.Context(ident=OWD.BIO_ENT_NS['worm0'], conf=conn.conf).stored

        print("Neurons:")
        print(", ".join(sorted(Neuron().name.get())))

        with ctx.stored(Worm, Neuron, Network) as cctx:
            w = cctx.Worm()
            net = cctx.Network()
            neur = cctx.Neuron()

            print(net.count())
import PyOpenWorm
from time import time
from PyOpenWorm.neuron import Neuron
PyOpenWorm.connect(configFile='PyOpenWorm/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))