示例#1
0
def test_strength_zscore():
    out = modularity.bipartmod_wrapper(F["simple_1"],seed=1).set_index("id")
    idx = ["A","B","C","D"]
    nt.assert_almost_equal(out.loc[idx,"z"].values, [0]*4)

    out = modularity.bipartmod_wrapper(F["simple_2"],seed=1).set_index("id")
    idx = ["A","B","C","D","E","F","G"]
    nt.assert_almost_equal(out.loc[idx,"z"].values, [0.57735027, -1.73205081,  0.57735027,  0.57735027,0,0,0],4)
示例#2
0
def test_degree_zscore():
    out = modularity.bipartmod_wrapper(F["simple_1"],seed=1,degree=1).set_index("id")
    idx = ["A","B","C","D"]
    nt.assert_almost_equal(out.loc[idx,"z"].values, [0]*4,)

    out = modularity.bipartmod_wrapper(F["simple_2"],seed=1,degree=1).set_index("id")
    idx = ["A","B","C","D","E","F","G"]
    nt.assert_almost_equal(out.loc[idx,"z"].values, [0]*7)
示例#3
0
def test_strength_participation():
    out = modularity.bipartmod_wrapper(F["simple_1"],seed=1).set_index("id")
    idx = ["A","B","C","D"]
    nt.assert_almost_equal(out.loc[idx,"P"].values, (0,0.5,.444,.444),3)

    out = modularity.bipartmod_wrapper(F["simple_2"],seed=1).set_index("id")
    idx = ["A","B","C","D","E","F","G"]
    nt.assert_almost_equal(out.loc[idx,"P"].values,  [0,0,0,.46875,0.4444,0.4444,0.4444],4)
示例#4
0
def test_modules_inverted():
    out = modularity.bipartmod_wrapper(F["women"],seed=1,inv=True)
    out = frozenset([frozenset(x.id.values) for m,x in out.groupby("module")])
    assert out == F["women_modules_inv"]

    out = modularity.bipartmod_wrapper(F["simple_2"],seed=1,inv=True)
    out = frozenset([frozenset(x.id.values) for m,x in out.groupby("module")])
    assert out == F["simple_2_modules_inv"]
示例#5
0
def test_modules_inverted():
    out = modularity.bipartmod_wrapper(F["women"], seed=1, inv=True)
    out = frozenset([frozenset(x.id.values) for m, x in out.groupby("module")])
    assert out == F["women_modules_inv"]

    out = modularity.bipartmod_wrapper(F["simple_2"], seed=1, inv=True)
    out = frozenset([frozenset(x.id.values) for m, x in out.groupby("module")])
    assert out == F["simple_2_modules_inv"]
示例#6
0
def test_strength_participation():
    out = modularity.bipartmod_wrapper(F["simple_1"], seed=1).set_index("id")
    idx = ["A", "B", "C", "D"]
    nt.assert_almost_equal(out.loc[idx, "P"].values, (0, 0.5, .444, .444), 3)

    out = modularity.bipartmod_wrapper(F["simple_2"], seed=1).set_index("id")
    idx = ["A", "B", "C", "D", "E", "F", "G"]
    nt.assert_almost_equal(out.loc[idx, "P"].values,
                           [0, 0, 0, .46875, 0.4444, 0.4444, 0.4444], 4)
示例#7
0
def test_strength_zscore():
    out = modularity.bipartmod_wrapper(F["simple_1"], seed=1).set_index("id")
    idx = ["A", "B", "C", "D"]
    nt.assert_almost_equal(out.loc[idx, "z"].values, [0] * 4)

    out = modularity.bipartmod_wrapper(F["simple_2"], seed=1).set_index("id")
    idx = ["A", "B", "C", "D", "E", "F", "G"]
    nt.assert_almost_equal(
        out.loc[idx, "z"].values,
        [0.57735027, -1.73205081, 0.57735027, 0.57735027, 0, 0, 0], 4)
示例#8
0
def test_degree_zscore():
    out = modularity.bipartmod_wrapper(F["simple_1"], seed=1,
                                       degree=1).set_index("id")
    idx = ["A", "B", "C", "D"]
    nt.assert_almost_equal(
        out.loc[idx, "z"].values,
        [0] * 4,
    )

    out = modularity.bipartmod_wrapper(F["simple_2"], seed=1,
                                       degree=1).set_index("id")
    idx = ["A", "B", "C", "D", "E", "F", "G"]
    nt.assert_almost_equal(out.loc[idx, "z"].values, [0] * 7)