# -*- coding: utf-8 -*-
#
# test_connect_one_to_one.py
#
# This file is part of NEST.
#
# Copyright (C) 2004 The NEST Initiative
#
# NEST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
import numpy as np
import unittest
from . import test_connect_helpers as hf
from .test_connect_parameters import TestParams
[docs]class TestOneToOne(TestParams):
# specify connection pattern
rule = 'one_to_one'
conn_dict = {'rule': rule}
# sizes of populations
N = 6
N1 = N
N2 = N
N_array = 1000
[docs] 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)
[docs] 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)
[docs]def suite():
suite = unittest.TestLoader().loadTestsFromTestCase(TestOneToOne)
return suite
[docs]def run():
runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite())
if __name__ == '__main__':
run()