def test_con_proba5(self): error = True try: NormalConnectionProba(threshold=0.5, mean=-2, std=0.5) error = False except ValueError: self.assertTrue(error)
def test_con_proba8(self): error = True try: NormalConnectionProba(threshold=0, mean=0, std=0) error = False except ValueError: self.assertFalse(error)
def test_con_proba1(self): error = True try: NormalConnectionProba(threshold=1, mean=10, std=2) error = False except ValueError: self.assertTrue(error)
def test_normal_proba_connection_between_cells(self): """ Compare NormalConnectionProba (which is truncated normal dist) with a regular truncated normal dist of the same size as the maximal all-to-all connections. The test will pass if difference between potential conn number is less than 0.95 """ std = 0.2 mean = 0.1 threshold = 0.4 # if Truncated Normal Dist pass this threshold - creates connection Dist.set_seed(13) cell_conn_proba = NormalConnectionProba(threshold=threshold, mean=mean, std=std) conn = self.pop2.connect(rule="all", cell_connection_proba=cell_conn_proba, seg_dist="uniform") conn.set_source([c.filter_secs("soma")(0.5) for c in self.pop1.cells]) conn.set_target(self.pop2.cells) conn.add_synapse("Exp2Syn").add_netcon() conn.build() # create Truncated Normal comparative distribution of the same size as maximal # all-to-all connections norm = np.abs(np.random.normal(loc=mean, scale=std, size=200 * 100)) non_zero_norm = np.count_nonzero(norm[norm > threshold]) non_zero_cell = [len(c.syns) for c in self.pop2.cells] non_zero_cell_sum = sum(non_zero_cell) # difference of connection number is less then 0.95 if non_zero_cell_sum > non_zero_norm: diff = non_zero_norm / non_zero_cell_sum else: diff = non_zero_cell_sum / non_zero_norm self.assertGreater(diff, 0.95)