def testConnectivity(self):
     self.setUpNetwork(self.conn_dict)
     # make sure all connections do exist
     M = connect_test_base.get_connectivity_matrix(self.pop1, self.pop2)
     connect_test_base.mpi_assert(M, np.identity(self.N), self)
     # make sure no connections were drawn from the target to the source
     # population
     M = connect_test_base.get_connectivity_matrix(self.pop2, self.pop1)
     connect_test_base.mpi_assert(M, np.zeros((self.N, self.N)), self)
 def testConnectivity(self):
     self.setUpNetwork(self.conn_dict)
     # make sure all connections do exist
     M = connect_test_base.get_connectivity_matrix(self.pop1, self.pop2)
     M_all = np.ones((len(self.pop2), len(self.pop1)))
     connect_test_base.mpi_assert(M, M_all, self)
     # make sure no connections were drawn from the target to the source
     # population
     M = connect_test_base.get_connectivity_matrix(self.pop2, self.pop1)
     M_none = np.zeros((len(self.pop1), len(self.pop2)))
     connect_test_base.mpi_assert(M, M_none, self)
 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 testInDegree(self):
     conn_params = self.conn_dict.copy()
     conn_params['allow_autapses'] = False
     conn_params['allow_multapses'] = False
     self.setUpNetwork(conn_params)
     # make sure the indegree is right
     M = connect_test_base.get_connectivity_matrix(self.pop1, self.pop2)
     inds = np.sum(M, axis=1)
     connect_test_base.mpi_assert(inds, self.Nin * np.ones(self.N2), self)
     # make sure no connections were drawn from the target to the source
     # population
     M = connect_test_base.get_connectivity_matrix(self.pop2, self.pop1)
     M_none = np.zeros((len(self.pop1), len(self.pop2)))
     connect_test_base.mpi_assert(M, M_none, self)
 def testTotalNumberOfConnections(self):
     conn_params = self.conn_dict.copy()
     self.setUpNetwork(conn_params)
     total_conn = len(nest.GetConnections(self.pop1, self.pop2))
     connect_test_base.mpi_assert(total_conn, self.Nconn, self)
     # make sure no connections were drawn from the target to the source
     # population
     M = connect_test_base.get_connectivity_matrix(self.pop2, self.pop1)
     M_none = np.zeros((len(self.pop1), len(self.pop2)))
     connect_test_base.mpi_assert(M, M_none, self)
Exemplo n.º 6
0
    def testAutapsesFalse(self):
        conn_params = self.conn_dict.copy()
        N = 10

        # test that autapses were excluded
        conn_params['p'] = 1. - 1. / N
        conn_params['allow_autapses'] = False
        pop = nest.Create('iaf_psc_alpha', N)
        nest.Connect(pop, pop, conn_params)
        M = connect_test_base.get_connectivity_matrix(pop, pop)
        connect_test_base.mpi_assert(np.diag(M), np.zeros(N), self)
    def testAutapsesFalse(self):
        conn_params = self.conn_dict.copy()
        N = 3

        # test that autapses were excluded
        conn_params['N'] = N * (N - 1)
        conn_params['allow_autapses'] = False
        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)
        connect_test_base.mpi_assert(np.diag(M), np.zeros(N), self)
    def testAutapsesTrue(self):
        conn_params = self.conn_dict.copy()
        N = 10
        conn_params['allow_multapses'] = False

        # test that autapses exist
        conn_params['p'] = 1.
        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)
        connect_test_base.mpi_assert(np.diag(M), np.ones(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)
Exemplo n.º 11
0
    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))