def test_project_different_n(): brain = Connectome(p=0.5, initialize=True) a = Area(n=3, k=1, beta=0.1) brain.add_area(a) b = Area(n=2, k=1, beta=0.1) brain.add_area(b) s = Stimulus(n=2, beta=0.1) brain.add_stimulus(s) brain.project({s: [a], a: [b]})
def test_init_connectomes_area(): """test for non lazy brain""" brain = Connectome(p=0, initialize=True) a = Area(n=3, k=1, beta=0.1) brain.add_area(a) assert all([ all([brain.connections[a, a][i, j] == 0 for i in range(3)]) for j in range(3) ]) assert brain.connections[a, a].beta == 0.1 brain = Connectome(p=1) a = Area(n=3, k=1, beta=0.1) brain.add_area(a) assert all([ all([brain.connections[a, a][i, j] == 1 for i in range(3)]) for j in range(3) ]) assert brain.connections[a, a].beta == 0.1
def test_project_no_winners(): brain = Connectome(p=0, initialize=True) a = Area(n=2, k=1, beta=0.1) brain.add_area(a) b = Area(n=2, k=1, beta=0.1) brain.add_area(b) s = Stimulus(n=1, beta=0.1) brain.add_stimulus(s) brain.connections[a, b][0, 0] = 1 brain.connections[a, b][0, 1] = 0 brain.connections[a, b][1, 0] = 0 brain.connections[a, b][1, 1] = 0 brain.connections[s, a][0, 0] = 1 brain.connections[s, a][0, 1] = 0 brain.project({s: [a], a: [b]})
def test_area_in_brain(): """test for non lazy connectome""" brain = Connectome(p=0, initialize=True) a = Area(n=3, k=1, beta=0.1) brain.add_area(a) assert a in brain.areas
def test_stimulus_in_brain(): """test for non lazy brain""" brain = Connectome(p=0, initialize=True) s = Stimulus(n=3, beta=0.1) brain.add_stimulus(s) assert s in brain.stimuli
def test_project_connectomes(): brain = Connectome(p=0, initialize=True) a = Area(n=2, k=1, beta=0.1) b = Area(n=2, k=1, beta=0.1) brain.add_area(a) brain.add_area(b) s = Stimulus(n=1, beta=0.1) brain.add_stimulus(s) brain.connections[a, b][0, 0] = 1 brain.connections[a, b][0, 1] = 0 brain.connections[a, b][1, 0] = 0 brain.connections[a, b][1, 1] = 0 brain.connections[s, a][0, 0] = 1 brain.connections[s, a][0, 1] = 0 brain.project({s: [a]}) print(brain.connections[a, b]) brain.project({a: [b]}) print(brain.connections[a, b]) print(a.winners) print(b.winners) assert abs(brain.connections[a, b][0, 0] - 1.1) < 0.0001