Beispiel #1
0
    def test_builder(self):
        nrn = (LogicalNeuron.on(NeuronBlockOnWafer()).add(
            NeuronOnNeuronBlock(), 5).done())
        self.assertFalse(nrn.is_external())
        self.assertTrue(str(nrn).startswith('LogicalNeuron::on('))
        with self.assertRaises(RuntimeError):
            nrn.external_identifier()
        with self.assertRaises(RuntimeError):
            nrn.external_index()

        with self.assertRaises(ValueError):
            no_chunks_specified = (LogicalNeuron.on(
                NeuronBlockOnWafer()).done())
Beispiel #2
0
 def test_add(self):
     pl = Placement()
     pl.add(BioNeuron(42, 0), LogicalNeuron.external(13))
     pl.add(BioNeuron(123, 0), (LogicalNeuron.on(NeuronBlockOnWafer()).add(
         NeuronOnNeuronBlock(X(2), Y(0)), 4).add(
             NeuronOnNeuronBlock(X(3), Y(1)), 2).done()))
     return pl
Beispiel #3
0
    def test_denmems(self):
        # |  XXXX
        # |   XX
        nrn = (LogicalNeuron.on(NeuronBlockOnWafer()).add(
            NeuronOnNeuronBlock(X(2), Y(0)),
            4).add(NeuronOnNeuronBlock(X(3), Y(1)), 2).done())
        reference_denmems = [
            NeuronOnWafer(NeuronOnHICANN(X(2), Y(0))),
            NeuronOnWafer(NeuronOnHICANN(X(3), Y(0))),
            NeuronOnWafer(NeuronOnHICANN(X(4), Y(0))),
            NeuronOnWafer(NeuronOnHICANN(X(5), Y(0))),
            NeuronOnWafer(NeuronOnHICANN(X(3), Y(1))),
            NeuronOnWafer(NeuronOnHICANN(X(4), Y(1))),
        ]

        self.assertFalse(nrn.is_external())
        self.assertEqual(6, nrn.size())
        self.assertEqual(reference_denmems[0], nrn.denmem(0))
        self.assertEqual(reference_denmems[1], nrn.denmem(1))
        self.assertEqual(reference_denmems[2], nrn.denmem(2))
        self.assertEqual(reference_denmems[3], nrn.denmem(3))
        self.assertEqual(reference_denmems[4], nrn.denmem(4))
        self.assertEqual(reference_denmems[5], nrn.denmem(5))
        with self.assertRaises(IndexError):
            nrn.denmem(6)
        self.assertSequenceEqual(reference_denmems, list(nrn))
        self.assertNotEqual(LogicalNeuron.external(12), nrn)
        self.assertEqual(nrn, nrn)
Beispiel #4
0
 def test_no_denmems(self):
     with self.assertRaises(ValueError):
         LogicalNeuron.on(NeuronBlockOnWafer()).done()