def test_hicann_copy(self): import copy h = redman.Hicann() h2 = copy.deepcopy(h) self.assertEqual(h, h2) # change something to ensure that it's not a mere pointer copy h.neurons().disable(NeuronOnHICANN()) self.assertNotEqual(h, h2)
def inject_disabled_component(self, attr, it): hicann = pyredman.Hicann() for component in it: getattr(hicann, attr)().disable(component) # Note: Overwrites values set by prior calls self.marocco.defects.inject(self.chip, hicann)
def test_hicann_pickle(self): import pickle h = redman.Hicann() h_str = pickle.dumps(h) h2 = pickle.loads(h_str) self.assertEqual(h, h2) # change something to ensure that it's not a mere pointer copy h.neurons().disable(NeuronOnHICANN()) self.assertNotEqual(h, h2)
def test_loss_in_wafer_routing(self, mode): h0 = HICANNGlobal(HICANNOnWafer(Enum(0)), Wafer(33)) h1 = HICANNGlobal(HICANNOnWafer(Enum(1)), Wafer(33)) # disable all horizontal buses on h0 hicann = pyredman.Hicann() for hbus in iter_all(HLineOnHICANN): hicann.hbuses().disable(hbus) self.marocco.defects.set(pyredman.Wafer()) self.marocco.defects.wafer().inject(h0, hicann) pynn.setup(marocco=self.marocco) n1 = 100 n2 = 100 p1 = pynn.Population(n1, pynn.EIF_cond_exp_isfa_ista) p2 = pynn.Population(n2, pynn.EIF_cond_exp_isfa_ista) self.marocco.manual_placement.on_hicann(p1, h0) self.marocco.manual_placement.on_hicann(p2, h1) n_post = 10 if mode == "Population": src = p1 tgt = p2 exp_loss = len(src) * n_post elif mode == "PopulationView": src = p1[n1 // 2:n1] tgt = p2[n2 // 2:n2] exp_loss = len(src) * n_post elif mode == "Assembly": src = pynn.Assembly(p1, p2) tgt = p2 exp_loss = len(p1) * n_post conn = pynn.FixedNumberPostConnector(n_post, allow_self_connections=True, weights=1.) proj = pynn.Projection(src, tgt, conn, target='excitatory') pynn.run(100) pynn.end() # check stats self.assertEqual(exp_loss, self.marocco.stats.getSynapseLossAfterL1Routing()) self.assertEqual(exp_loss, self.marocco.stats.getSynapseLoss()) # check weight matrices orig_weights = proj.getWeights(format="array") mapped_weights = self.marocco.stats.getWeights(proj) lost_syns = np.logical_and(np.isfinite(orig_weights), np.isnan(mapped_weights)) self.assertEqual(exp_loss, np.count_nonzero(lost_syns))