def test_build_input(self): mat_in, mat_out = test_data() net = NetworkBuilder(mat_in, mat_out) times, indices, split = net.build_input() self.assertEqual([[100.0], [100.0], [0.0, 200.0], [200.0], [0.0]], times) self.assertEqual([[1], [1], [0, 2], [2], [0]], indices) self.assertEqual([3], split) times, indices, split = net.build_input( topology_params={"multiplicity": 2}) self.assertEqual([[100.0], [100.0], [100.0], [100.0], [0.0, 200.0], [0.0, 200.0], [200.0], [200.0], [0.0], [0.0]], times) self.assertEqual( [[1], [1], [1], [1], [0, 2], [0, 2], [2], [2], [0], [0]], indices) self.assertEqual([3], split) times, indices, split = net.build_input( topology_params={"multiplicity": 2}, input_params={"burst_size": 3}) self.assertEqual( [[100.0, 101.0, 102.0], [100.0, 101.0, 102.0], [ 100.0, 101.0, 102.0 ], [100.0, 101.0, 102.0], [0.0, 1.0, 2.0, 200.0, 201.0, 202.0], [0.0, 1.0, 2.0, 200.0, 201.0, 202.0], [200.0, 201.0, 202.0], [200.0, 201.0, 202.0], [0.0, 1.0, 2.0], [0.0, 1.0, 2.0]], times) self.assertEqual( [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [0, 0, 0, 2, 2, 2], [0, 0, 0, 2, 2, 2], [2, 2, 2], [2, 2, 2], [0, 0, 0], [0, 0, 0]], indices) self.assertEqual([3], split)
def test_build_input(self): mat_in, mat_out = test_data() net = NetworkBuilder(mat_in, mat_out) times, indices, split = net.build_input() self.assertEqual([[100.0], [100.0], [0.0, 200.0], [200.0], [0.0]], times) self.assertEqual([[1], [1], [0, 2], [2], [0]], indices) self.assertEqual([3], split) times, indices, split = net.build_input( topology_params={"multiplicity": 2}) self.assertEqual([[100.0], [100.0], [100.0], [100.0], [0.0, 200.0], [0.0, 200.0], [200.0], [200.0], [0.0], [0.0]], times) self.assertEqual([[1], [1], [1], [1], [0, 2], [0, 2], [2], [2], [0], [0]], indices) self.assertEqual([3], split) times, indices, split = net.build_input( topology_params={"multiplicity": 2}, input_params={"burst_size": 3}) self.assertEqual([[100.0, 101.0, 102.0], [100.0, 101.0, 102.0], [100.0, 101.0, 102.0], [100.0, 101.0, 102.0], [0.0, 1.0, 2.0, 200.0, 201.0, 202.0], [0.0, 1.0, 2.0, 200.0, 201.0, 202.0], [200.0, 201.0, 202.0], [200.0, 201.0, 202.0], [0.0, 1.0, 2.0], [0.0, 1.0, 2.0]], times) self.assertEqual([[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [0, 0, 0, 2, 2, 2], [0, 0, 0, 2, 2, 2], [2, 2, 2], [2, 2, 2], [0, 0, 0], [0, 0, 0]], indices) self.assertEqual([3], split)
def test_build_multi_input(self): mat_in, mat_out = test_data2() net = NetworkBuilder(mat_in, mat_out) times, indices, split = net.build_input( topology_params={"multiplicity": 2}, input_params=[{ "burst_size": 3 }, { "burst_size": 2, "isi": 4.0 }]) self.assertEqual([[ 100.0, 101.0, 102.0, 1300.0, 1304.0 ], [ 100.0, 101.0, 102.0, 1300.0, 1304.0 ], [ 0.0, 1.0, 2.0, 100.0, 101.0, 102.0, 1200.0, 1204.0, 1300.0, 1304.0 ], [ 0.0, 1.0, 2.0, 100.0, 101.0, 102.0, 1200.0, 1204.0, 1300.0, 1304.0 ], [], [], [0.0, 1.0, 2.0, 1200.0, 1204.0], [0.0, 1.0, 2.0, 1200.0, 1204.0]], times) self.assertEqual( [[1, 1, 1, 3, 3], [1, 1, 1, 3, 3], [0, 0, 0, 1, 1, 1, 2, 2, 3, 3], [0, 0, 0, 1, 1, 1, 2, 2, 3, 3], [], [], [0, 0, 0, 2, 2], [0, 0, 0, 2, 2]], indices) self.assertEqual([2, 4], split)
def test_build_multi_input(self): mat_in, mat_out = test_data2() net = NetworkBuilder(mat_in, mat_out) times, indices, split = net.build_input( topology_params={"multiplicity": 2}, input_params=[{"burst_size": 3}, {"burst_size": 2, "isi": 4.0}]) self.assertEqual([ [100.0, 101.0, 102.0, 1300.0, 1304.0], [100.0, 101.0, 102.0, 1300.0, 1304.0], [0.0, 1.0, 2.0, 100.0, 101.0, 102.0, 1200.0, 1204.0, 1300.0, 1304.0], [0.0, 1.0, 2.0, 100.0, 101.0, 102.0, 1200.0, 1204.0, 1300.0, 1304.0], [], [], [0.0, 1.0, 2.0, 1200.0, 1204.0], [0.0, 1.0, 2.0, 1200.0, 1204.0]], times) self.assertEqual([ [1, 1, 1, 3, 3], [1, 1, 1, 3, 3], [0, 0, 0, 1, 1, 1, 2, 2, 3, 3], [0, 0, 0, 1, 1, 1, 2, 2, 3, 3], [], [], [0, 0, 0, 2, 2], [0, 0, 0, 2, 2]], indices) self.assertEqual([2, 4], split)