def test_RemoveNeuronWithLinks(self): net = NeuralNet() n1 = net.add_neuron() n2 = net.add_neuron() lnk = net.add_link(n1, n2) self.assertTrue(len(net.Neurons) == 2) self.assertTrue(len(n1.Incoming) == 0) self.assertTrue(len(n1.Outgoing) == 1) self.assertTrue(n1.Outgoing[0] == lnk) self.assertTrue(len(n2.Incoming) == 1) self.assertTrue(len(n2.Outgoing) == 0) self.assertTrue(n2.Incoming[0] == lnk) self.assertEqual(n1.is_connected_outgoing(n2), lnk) self.assertEqual(n1.is_connected_incoming(n2), None) self.assertEqual(n2.is_connected_outgoing(n1), None) self.assertEqual(n2.is_connected_incoming(n1), lnk) net.remove_neuron(n1) self.assertTrue(len(net.Neurons) == 1) self.assertTrue(len(n1.Incoming) == 0) self.assertTrue(len(n1.Outgoing) == 0) self.assertTrue(len(n2.Incoming) == 0) self.assertTrue(len(n2.Outgoing) == 0) self.assertEqual(n1.is_connected_outgoing(n2), None) self.assertEqual(n1.is_connected_incoming(n2), None) self.assertEqual(n2.is_connected_outgoing(n1), None) self.assertEqual(n2.is_connected_incoming(n1), None)
def test_RemoveNeuronNoLinks(self): net = NeuralNet() n1 = net.add_neuron() n2 = net.add_neuron() self.assertTrue(len(net.Neurons) == 2) net.remove_neuron(n2) self.assertTrue(len(net.Neurons) == 1) self.assertTrue(net.Neurons[0] == n1) n2 = net.add_neuron() self.assertTrue(len(net.Neurons) == 2) net.remove_neuron(n1) self.assertTrue(len(net.Neurons) == 1) self.assertTrue(net.Neurons[0] == n2)