def testStatistics(self): conn_params = self.conn_dict.copy() conn_params['allow_autapses'] = True conn_params['allow_multapses'] = True conn_params['N'] = self.N for fan in ['in', 'out']: expected = connect_test_base.get_expected_degrees_totalNumber( self.N, fan, self.N_s, self.N_t) pvalues = [] for i in range(self.stat_dict['n_runs']): connect_test_base.reset_seed(i + 1, self.nr_threads) self.setUpNetwork(conn_dict=conn_params, N1=self.N_s, N2=self.N_t) degrees = connect_test_base.get_degrees( fan, self.pop1, self.pop2) degrees = connect_test_base.gather_data(degrees) if degrees is not None: chi, p = connect_test_base.chi_squared_check( degrees, expected) pvalues.append(p) connect_test_base.mpi_barrier() p = None if degrees is not None: ks, p = scipy.stats.kstest(pvalues, 'uniform') p = connect_test_base.bcast_data(p) self.assertGreater(p, self.stat_dict['alpha2'])
def testSymmetricFlag(self): conn_dict_symmetric = self.conn_dict.copy() conn_dict_symmetric['make_symmetric'] = True self.setUpNetwork(conn_dict_symmetric) M1 = connect_test_base.get_connectivity_matrix(self.pop1, self.pop2) M2 = connect_test_base.get_connectivity_matrix(self.pop2, self.pop1) # test that connections were created in both directions connect_test_base.mpi_assert( M1, np.transpose(connect_test_base.gather_data(M2)), self) # test that no other connections were created connect_test_base.mpi_assert(M1, np.zeros_like(M1) + np.identity(self.N), self)
def testMultapsesFalse(self): conn_params = self.conn_dict.copy() N = 3 conn_params['allow_autapses'] = True # test that no multapses exist conn_params['indegree'] = N conn_params['allow_multapses'] = False pop = nest.Create('iaf_psc_alpha', N) nest.Connect(pop, pop, conn_params) M = connect_test_base.get_connectivity_matrix(pop, pop) M = connect_test_base.gather_data(M) if M is not None: self.assertTrue(M.flatten, np.ones(N * N))
def testAutapsesTrue(self): conn_params = self.conn_dict.copy() N = 3 # test that autapses exist conn_params['N'] = N * N * N conn_params['allow_autapses'] = True pop = nest.Create('iaf_psc_alpha', N) nest.Connect(pop, pop, conn_params) # make sure all connections do exist M = connect_test_base.get_connectivity_matrix(pop, pop) M = connect_test_base.gather_data(M) if M is not None: self.assertTrue(np.sum(np.diag(M)) > N)
def testMakeSymmetric(self): conn_params = self.conn_dict.copy() N = 100 # test that all connections are symmetric conn_params['make_symmetric'] = True nest.ResetKernel() pop = nest.Create('iaf_psc_alpha', N) nest.Connect(pop, pop, conn_params) M = connect_test_base.get_connectivity_matrix(pop, pop) print(M) M_all = connect_test_base.gather_data(M) print(M_all) if M_all is not None: self.assertTrue(np.array_equal(M_all, M_all.T))
def testRPortDistribution(self): n_rport = 10 nr_neurons = 100 nest.ResetKernel() # To reset local_num_threads neuron_model = 'iaf_psc_exp_multisynapse' neuron_dict = {'tau_syn': [0.1 + i for i in range(n_rport)]} self.pop1 = nest.Create(neuron_model, nr_neurons, neuron_dict) self.pop2 = nest.Create(neuron_model, nr_neurons, neuron_dict) syn_params = {'synapse_model': 'static_synapse'} syn_params['receptor_type'] = 1 + nest.random.uniform_int(n_rport) nest.Connect(self.pop1, self.pop2, self.conn_dict, syn_params) M = connect_test_base.get_weighted_connectivity_matrix( self.pop1, self.pop2, 'receptor') M = connect_test_base.gather_data(M) if M is not None: M = M.flatten() frequencies = scipy.stats.itemfreq(M) self.assertTrue( np.array_equal(frequencies[:, 0], np.arange(1, n_rport + 1)), 'Missing or invalid rports') chi, p = scipy.stats.chisquare(frequencies[:, 1]) self.assertGreater(p, self.pval)
def testStatistics(self): for fan in ['in', 'out']: expected = connect_test_base.get_expected_degrees_bernoulli( self.p, fan, self.N_s, self.N_t) pvalues = [] for i in range(self.stat_dict['n_runs']): connect_test_base.reset_seed(i + 1, self.nr_threads) self.setUpNetwork(conn_dict=self.conn_dict, N1=self.N_s, N2=self.N_t) degrees = connect_test_base.get_degrees( fan, self.pop1, self.pop2) degrees = connect_test_base.gather_data(degrees) # degrees = self.comm.gather(degrees, root=0) # if self.rank == 0: if degrees is not None: chi, p = connect_test_base.chi_squared_check( degrees, expected, self.rule) pvalues.append(p) connect_test_base.mpi_barrier() if degrees is not None: ks, p = scipy.stats.kstest(pvalues, 'uniform') self.assertTrue(p > self.stat_dict['alpha2'])