Exemple #1
0
    def test_can_create_cyclical_network(self):
        a = model.NotNeuron(None)
        a.inputs = [a]

        net = model.Network(a)

        self.assertEqual(list(net), [a])
Exemple #2
0
 def build_net(a, b):
     """
     [1] Built as guided by the description provided.
     For the equation of the network, see:
     http://hyperphysics.phy-astr.gsu.edu/hbase/electronic/ietron/xor4.gif
     """
     return model.AndNeuron(
         model.OrNeuron(a, b),
         model.NotNeuron(model.AndNeuron(a, b))
     ),
Exemple #3
0
    def test_not_neuron(self):
        a = model.Input("a")
        gate = model.NotNeuron(a)

        a.state = 0
        gate.update()
        self.assertEquals(gate.state, 1)

        a.state = 1
        gate.update()
        self.assertEquals(gate.state, 0)
Exemple #4
0
 def test_cyclical_network_is_self_propelling(self):
     a = model.NotNeuron(None, state=0)
     a.inputs = [a]
     net = model.Network(a)
     self.assertEqual(a.state, 0)
     net.update()
     self.assertEqual(a.state, 1)
     net.update()
     self.assertEqual(a.state, 0)
     net.update()
     self.assertEqual(a.state, 1)
     net.update()
     self.assertEqual(a.state, 0)
Exemple #5
0
 def test_cyclical_network_doesnt_explode_during_update(self):
     a = model.NotNeuron(None)
     a.inputs = [a]
     net = model.Network(a)
     net.update()