예제 #1
0
파일: tests.py 프로젝트: guyde2011/Brain
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]})
예제 #2
0
파일: tests.py 프로젝트: guyde2011/Brain
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
예제 #3
0
파일: tests.py 프로젝트: guyde2011/Brain
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]})
예제 #4
0
파일: tests.py 프로젝트: guyde2011/Brain
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
예제 #5
0
파일: tests.py 프로젝트: guyde2011/Brain
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
예제 #6
0
파일: tests.py 프로젝트: guyde2011/Brain
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