コード例 #1
0
ファイル: test_modularity.py プロジェクト: klarnemann/brainx
def test_sim_anneal_simple():
    """Very simple simulated_annealing test with a small network"""

    #
    nnod, nmod, av_degree, btwn_frac = 24, 3, 4, 0
    g = mod.random_modular_graph(nnod, nmod, av_degree, btwn_frac)

    #Compute the # of nodes per module
    ## nnod_mod = nnod/nmod
    #Make a "correct" partition for the graph
    ## ppart = mod.perfect_partition(nmod,nnod_mod)

    temperature = 10
    temp_scaling = 0.95
    tmin = 1

    graph_out, graph_dict = mod.simulated_annealing(g,
                                                    temperature=temperature,
                                                    temp_scaling=temp_scaling,
                                                    tmin=tmin,
                                                    extra_info=True,
                                                    debug=True)

    # Ensure that there are no empty modules
    util.assert_no_empty_modules(graph_out.index)
コード例 #2
0
ファイル: test_util.py プロジェクト: EhsanTadayon/brainx
def test_no_empty_modules():
    """Test the utility that validates partitions against empty modules.
    """
    a = {0: [1, 2], 1: [3, 4]}
    b = a.copy()
    b[2] = []
    util.assert_no_empty_modules(a)
    nt.assert_raises(ValueError, util.assert_no_empty_modules, b)
コード例 #3
0
ファイル: test_util.py プロジェクト: klarnemann/brainx
def test_no_empty_modules():
    """Test the utility that validates partitions against empty modules.
    """
    a = {0: [1, 2], 1: [3, 4]}
    b = a.copy()
    b[2] = []
    util.assert_no_empty_modules(a)
    nt.assert_raises(ValueError, util.assert_no_empty_modules, b)
コード例 #4
0
def test_sim_anneal_simple():
    """Very simple simulated_annealing test with a small network"""

    #
    nnod, nmod, av_degree, btwn_frac = 24, 3, 4, 0
    g = mod.random_modular_graph(nnod, nmod, av_degree, btwn_frac)

    #Compute the # of nodes per module
    ## nnod_mod = nnod/nmod
    #Make a "correct" partition for the graph
    ## ppart = mod.perfect_partition(nmod,nnod_mod)

    temperature = 10
    temp_scaling = 0.95
    tmin=1

    graph_out, graph_dict = mod.simulated_annealing(g,
               temperature = temperature, temp_scaling = temp_scaling,
               tmin=tmin, extra_info = True, debug=True)

    # Ensure that there are no empty modules
    util.assert_no_empty_modules(graph_out.index)