def testInputArrayToStdpSynapse(self): params = ['Wmax', 'alpha', 'lambda', 'mu_minus', 'mu_plus', 'tau_plus'] syn_params = {'synapse_model': 'stdp_synapse'} values = [np.arange(self.N1, dtype=float) for i in range(6)] for i, param in enumerate(params): syn_params[param] = values[i] self.setUpNetwork(self.conn_dict, syn_params) for i, param in enumerate(params): a = connect_test_base.get_weighted_connectivity_matrix( self.pop1, self.pop2, param) connect_test_base.mpi_assert(np.diag(a), values[i], self)
def testInputArrayRPort(self): syn_params = {} neuron_model = 'iaf_psc_exp_multisynapse' neuron_dict = {'tau_syn': [0.1 + i for i in range(self.N1)]} self.pop1 = nest.Create(neuron_model, self.N1, neuron_dict) self.pop2 = nest.Create(neuron_model, self.N1, neuron_dict) self.param_array = np.arange(1, self.N1 + 1, dtype=int) syn_params['receptor_type'] = self.param_array nest.Connect(self.pop1, self.pop2, self.conn_dict, syn_params) M = connect_test_base.get_weighted_connectivity_matrix( self.pop1, self.pop2, 'receptor') connect_test_base.mpi_assert(M, np.diag(self.param_array), self)
def testInputArrayWithoutAutapses(self): self.conn_dict['allow_autapses'] = False for label in ['weight', 'delay']: syn_params = {} if label == 'weight': self.param_array = np.arange(self.N1 * self.N1, dtype=float).reshape( self.N1, self.N1) elif label == 'delay': self.param_array = np.arange(1, self.N1 * self.N1 + 1).reshape( self.N1, self.N1) * 0.1 syn_params[label] = self.param_array self.setUpNetworkOnePop(self.conn_dict, syn_params) M_nest = connect_test_base.get_weighted_connectivity_matrix( self.pop, self.pop, label) np.fill_diagonal(self.param_array, 0) connect_test_base.mpi_assert(M_nest, self.param_array, self)
def testInputArray(self): syn_params = {} for label in ['weight', 'delay']: if label == 'weight': self.param_array = np.arange(self.N_array, dtype=float) elif label == 'delay': self.param_array = np.arange(1, self.N_array + 1) * 0.1 syn_params[label] = self.param_array nest.ResetKernel() self.setUpNetwork(self.conn_dict, syn_params, N1=self.N_array, N2=self.N_array) M_nest = connect_test_base.get_weighted_connectivity_matrix( self.pop1, self.pop2, label) connect_test_base.mpi_assert(M_nest, np.diag(self.param_array), self)
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)