Example #1
0
        '''
        Test entirely run only if NEST is present on the computer.
        Check that delay distribution generated in NNGT, then in NEST, is
        conform to what was instructed.
        '''
        di_distrib = instructions["weights"]
        distrib = di_distrib["distribution"]
        delays = graph.set_delays(distribution=distrib, parameters=di_distrib)
        ref_result = _results_theo(instructions)
        computed_result = _results_exp(delays, instructions)
        self.assertTrue(
            np.allclose(ref_result, computed_result, self.tolerance),
            '''Error on graph {}: unequal delays for tolerance {}.
            '''.format(graph.name, self.tolerance))
        # @todo
        #~ if nngt._config['with_nest']:
        #~ from nngt.simulation import make_nest_network
        #~ gids = make_nest_network(graph)


#-----------------------------------------------------------------------------#
# Test suite
#------------------------
#

suite = unittest.TestLoader().loadTestsFromTestCase(TestAttributes)

if __name__ == "__main__":
    nngt.use_library("networkx")
    unittest.main()
Example #2
0
from os import listdir, environ
from os.path import abspath, dirname, isfile
import unittest

# personal library
import nngt

#-----------------------------------------------------------------------------#
# Get the tests
#------------------------
#

# get the arguments
graph_library = environ.get("GL", None)
if graph_library == "gt":
    nngt.use_library("graph-tool")
    assert nngt.get_config('graph_library') == "graph-tool", \
           "Loading graph-tool failed..."
elif graph_library == "ig":
    nngt.use_library("igraph")
    assert nngt.get_config('graph_library') == "igraph", \
           "Loading igraph failed..."
elif graph_library == "nx":
    nngt.use_library("networkx")
    assert nngt.get_config('graph_library') == "networkx", \
           "Loading networkx failed..."

omp = int(environ.get("OMP", 1))
nngt.set_config({"omp": omp})

# get the tests
Example #3
0
nest.SetKernelStatus({"local_num_threads": 8})

from nngt.core import GraphObject
from nngt.simulation import make_nest_network, get_nest_network
from graph_tool.generation import random_rewire



#-----------------------------------------------------------------------------#
# Build networks
#------------------------
#

#~ nngt.use_library("igraph")
nngt.use_library("networkx")

nmodel = "iaf_neuron"
nparam = { "t_ref": 2. }

pop = nngt.NeuralPop.ei_population(1000, en_model=nmodel, in_model=nmodel, en_param=nparam, in_param=nparam)
graph = nngt.SpatialNetwork(pop, weight_prop={"distrib":"gaussian", "distrib_prop":{"avg_distrib": 60.}})
#~ graph = nngt.SpatialNetwork(pop, weight_prop={"distrib":"lognormal"})
nngt.generation.connect_neural_types(graph, 1, -1, "erdos_renyi", {"density": 0.035})
#~ nngt.generation.connect_neural_types(graph, 1, 1, "newman_watts", {"coord_nb":10, "proba_shortcut": 0.1})
#~ nngt.generation.connect_neural_types(graph, 1, 1, "random_scale_free", {"in_exp": 2.1, "out_exp": 2.9, "density": 0.065})
nngt.generation.connect_neural_types(graph, 1, 1, "erdos_renyi", {"density": 0.077})
nngt.generation.connect_neural_types(graph, -1, 1, "erdos_renyi", {"density": 0.2})
nngt.generation.connect_neural_types(graph, -1, -1, "erdos_renyi", {"density": 0.04})

Example #4
0
import unittest

# personal library
import nngt



#-----------------------------------------------------------------------------#
# Get the tests
#------------------------
#

# get the arguments
graph_library = environ.get("GL", None)
if graph_library == "gt":
    nngt.use_library("graph-tool")
elif graph_library == "ig":
    nngt.use_library("igraph")
elif graph_library == "nx":
    nngt.use_library("networkx")

# get the tests
current_dir = dirname(abspath(__file__))
dir_files = listdir(current_dir)
sys.path.insert(0, current_dir)
testfiles = [fname[:-3] for fname in dir_files if (fname.startswith("test_") 
             and fname.endswith(".py"))]
tests = [importlib.import_module(name) for name in testfiles]


#-----------------------------------------------------------------------------#