Exemple #1
0
 def testConnectivity(self):
     self.setUpNetwork(self.conn_dict)
     # make sure all connections do exist
     M = hf.get_connectivity_matrix(self.pop1, self.pop2)
     hf.mpi_assert(M, np.identity(self.N), self)
     # make sure no connections were drawn from the target to the source
     # population
     M = hf.get_connectivity_matrix(self.pop2, self.pop1)
     hf.mpi_assert(M, np.zeros((self.N, self.N)), self)
Exemple #2
0
 def testSymmetricFlag(self):
     conn_dict_symmetric = self.conn_dict.copy()
     conn_dict_symmetric['make_symmetric'] = True
     self.setUpNetwork(conn_dict_symmetric)
     M1 = hf.get_connectivity_matrix(self.pop1, self.pop2)
     M2 = hf.get_connectivity_matrix(self.pop2, self.pop1)
     # test that connections were created in both directions
     hf.mpi_assert(M1, np.transpose(hf.gather_data(M2)), self)
     # test that no other connections were created
     hf.mpi_assert(M1, np.zeros_like(M1) + np.identity(self.N), self)
Exemple #3
0
 def testConnectivity(self):
     self.setUpNetwork(self.conn_dict)
     # make sure all connections do exist
     M = hf.get_connectivity_matrix(self.pop1, self.pop2)
     M_all = np.ones((len(self.pop2), len(self.pop1)))
     hf.mpi_assert(M, M_all, self)
     # make sure no connections were drawn from the target to the source
     # population
     M = hf.get_connectivity_matrix(self.pop2, self.pop1)
     M_none = np.zeros((len(self.pop1), len(self.pop2)))
     hf.mpi_assert(M, M_none, self)
Exemple #4
0
 def testOutDegree(self):
     conn_params = self.conn_dict.copy()
     conn_params['allow_autapses'] = False
     conn_params['allow_multapses'] = False
     self.setUpNetwork(conn_params)
     # make sure the outdegree is right
     M = hf.get_connectivity_matrix(self.pop1, self.pop2)
     outds = np.sum(M, axis=0)
     hf.mpi_assert(outds, self.Nout * np.ones(self.N1), self)
     # make sure no connections were drawn from the target to the source
     # population
     M = hf.get_connectivity_matrix(self.pop2, self.pop1)
     M_none = np.zeros((len(self.pop1), len(self.pop2)))
     hf.mpi_assert(M, M_none, self)
Exemple #5
0
    def testAutapsesFalse(self):
        conn_params = self.conn_dict.copy()

        # test that autapses were excluded
        conn_params['allow_autapses'] = False
        self.pop1 = hf.nest.Create('iaf_psc_alpha', self.N1)
        hf.nest.Connect(self.pop1, self.pop1, conn_params)
        # make sure all connections do exist
        M = hf.get_connectivity_matrix(self.pop1, self.pop1)
        hf.mpi_assert(np.diag(M), np.zeros(self.N1), self)
Exemple #6
0
 def testTotalNumberOfConnections(self):
     conn_params = self.conn_dict.copy()
     self.setUpNetwork(conn_params)
     total_conn = len(hf.nest.GetConnections(self.pop1, self.pop2))
     hf.mpi_assert(total_conn, self.Nconn, self)
     # make sure no connections were drawn from the target to the source
     # population
     M = hf.get_connectivity_matrix(self.pop2, self.pop1)
     M_none = np.zeros((len(self.pop1), len(self.pop2)))
     hf.mpi_assert(M, M_none, self)
Exemple #7
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 = hf.nest.Create('iaf_psc_alpha', N)
        hf.nest.Connect(pop, pop, conn_params)
        M = hf.get_connectivity_matrix(pop, pop)
        hf.mpi_assert(np.diag(M), np.zeros(N), self)
Exemple #8
0
    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 = hf.nest.Create('iaf_psc_alpha', N)
        hf.nest.Connect(pop, pop, conn_params)
        # make sure all connections do exist
        M = hf.get_connectivity_matrix(pop, pop)
        hf.mpi_assert(np.diag(M), np.zeros(N), self)
Exemple #9
0
    def testAutapsesTrue(self):
        conn_params = self.conn_dict.copy()
        N = 10
        conn_params['allow_multapses'] = False

        # test that autapses exist
        conn_params['outdegree'] = N
        conn_params['allow_autapses'] = True
        pop = hf.nest.Create('iaf_psc_alpha', N)
        hf.nest.Connect(pop, pop, conn_params)
        # make sure all connections do exist
        M = hf.get_connectivity_matrix(pop, pop)
        hf.mpi_assert(np.diag(M), np.ones(N), self)
Exemple #10
0
    def testMultapsesFalse(self):
        conn_params = self.conn_dict.copy()
        N = 3
        conn_params['allow_autapses'] = True

        # test that no multapses exist
        conn_params['outdegree'] = N
        conn_params['allow_multapses'] = False
        pop = hf.nest.Create('iaf_psc_alpha', N)
        hf.nest.Connect(pop, pop, conn_params)
        M = hf.get_connectivity_matrix(pop, pop)
        M = hf.gather_data(M)
        if M is not None:
            self.assertTrue(M.flatten, np.ones(N * N))
Exemple #11
0
    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 = hf.nest.Create('iaf_psc_alpha', N)
        hf.nest.Connect(pop, pop, conn_params)
        # make sure all connections do exist
        M = hf.get_connectivity_matrix(pop, pop)
        M = hf.gather_data(M)
        if M is not None:
            self.assertTrue(np.sum(np.diag(M)) > N)