Commit 61d8cebd authored by Tiago Peixoto's avatar Tiago Peixoto

Assorted docstring fixes

parent 22cf7c5a
......@@ -578,7 +578,7 @@ def eigenvector(g, weight=None, vprop=None, epsilon=1e-6, max_iter=None):
>>> w.a = np.random.random(len(w.a)) * 42
>>> ee, x = gt.eigenvector(g, w)
>>> print(ee)
0.0013713102236792602
729.229595705175
>>> gt.graph_draw(g, pos=g.vp["pos"], vertex_fill_color=x,
... vertex_size=gt.prop_to_size(x, mi=5, ma=15),
... vorder=x, output="polblogs_eigenvector.pdf")
......
......@@ -516,7 +516,7 @@ def motif_significance(g, k, n_shuffles=100, p=1.0, motif_list=None,
>>> print(len(motifs))
11
>>> print(zscores)
[1.0170744045563587, 0.90350945788797254, 0.93486676613275743, -0.84952469609377301, -0.95933706030135635, -0.68770434820213655, -0.24381350447066388, 0.88, -0.12, -0.35, -0.21]
[0.91152284386957971, 0.79611981715847313, 0.75844561796064847, -0.69370586236292986, -0.83494968780939771, -0.58698299759329431, -0.25891660868480709, 0.89, -0.07, -0.29, -0.17]
"""
......
......@@ -328,7 +328,7 @@ def nested_mcmc_sweep(state, beta=1., random_move=False, c=1., sequential=True,
>>> state = gt.NestedBlockState(g, Bs=[10, 5, 3, 2, 1], deg_corr=True)
>>> ret = gt.nested_mcmc_sweep(state)
>>> print(ret)
[(-0.11881394061738723, 58), (-1.2855474804244876e-05, 1), (0.0, 0), (-0.003488958656098635, 1), (0.0, 0)]
[(-0.11881394061738723, 58), (0.0, 0), (0.0, 0), (-0.00108916046910437, 1), (0.0, 0)]
References
----------
......
......@@ -115,7 +115,7 @@ def assortativity(g, deg):
... vertex_corr=lambda i,k: 1.0 / (1 + abs(i - k)), directed=False,
... n_iter=100)
>>> gt.assortativity(g, "out")
(0.1419534824769149, 0.005098622437085927)
(0.1427961503065472, 0.005111874804434137)
References
----------
......@@ -191,13 +191,13 @@ def scalar_assortativity(g, deg):
... vertex_corr=lambda i,k: abs(i-k),
... directed=False, n_iter=100)
>>> gt.scalar_assortativity(g, "out")
(-0.45182410730944034, 0.010288182870044639)
(-0.4447873152401369, 0.010434117272182804)
>>> g = gt.random_graph(1000, lambda: sample_k(40), model="probabilistic",
... vertex_corr=lambda i, k: 1.0 / (1 + abs(i - k)),
... directed=False, n_iter=100)
>>> gt.scalar_assortativity(g, "out")
(0.6421210898147616, 0.010632143985746339)
(0.6014583531475572, 0.011588069772198617)
References
----------
......
......@@ -611,7 +611,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
gt.graph_draw(g, pos=pos, output="rewire_orig.png", output_size=(300, 300))
>>> gt.random_rewire(g, "correlated")
212
641
>>> pos = gt.arf_layout(g)
>>> gt.graph_draw(g, pos=pos, output="rewire_corr.pdf", output_size=(300, 300))
<...>
......@@ -622,7 +622,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
gt.graph_draw(g, pos=pos, output="rewire_corr.png", output_size=(300, 300))
>>> gt.random_rewire(g)
207
186
>>> pos = gt.arf_layout(g)
>>> gt.graph_draw(g, pos=pos, output="rewire_uncorr.pdf", output_size=(300, 300))
<...>
......@@ -633,7 +633,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
gt.graph_draw(g, pos=pos, output="rewire_uncorr.png", output_size=(300, 300))
>>> gt.random_rewire(g, "erdos")
21
13
>>> pos = gt.arf_layout(g)
>>> gt.graph_draw(g, pos=pos, output="rewire_erdos.pdf", output_size=(300, 300))
<...>
......@@ -664,17 +664,17 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-", label="Original")
<...>
>>> gt.random_rewire(g, "correlated")
212
230
>>> corr = gt.avg_neighbour_corr(g, "out", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="*", label="Correlated")
<...>
>>> gt.random_rewire(g)
120
102
>>> corr = gt.avg_neighbour_corr(g, "out", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-", label="Uncorrelated")
<...>
>>> gt.random_rewire(g, "erdos")
20
18
>>> corr = gt.avg_neighbour_corr(g, "out", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-", label=r"Erd\H{o}s")
<...>
......@@ -720,7 +720,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
... label=r"$\left<\text{i}\right>$ vs o")
<...>
>>> gt.random_rewire(g, "correlated")
4130
4185
>>> corr = gt.avg_neighbour_corr(g, "in", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-",
... label=r"$\left<\text{o}\right>$ vs i, corr.")
......@@ -730,7 +730,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
... label=r"$\left<\text{i}\right>$ vs o, corr.")
<...>
>>> gt.random_rewire(g, "uncorrelated")
194
161
>>> corr = gt.avg_neighbour_corr(g, "in", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-",
... label=r"$\left<\text{o}\right>$ vs i, uncorr.")
......
......@@ -127,7 +127,7 @@ def similarity(g1, g2, label1=None, label2=None, norm=True):
>>> gt.similarity(u, g)
1.0
>>> gt.random_rewire(u)
21
19
>>> gt.similarity(u, g)
0.03
"""
......@@ -616,8 +616,8 @@ def topological_sort(g):
>>> g.set_edge_filter(tree)
>>> sort = gt.topological_sort(g)
>>> print(sort)
[ 1 14 2 7 17 0 3 4 5 6 8 9 22 10 11 12 13 16 23 27 15 18 19 20 21
24 25 26 28 29]
[ 1 7 17 0 9 2 3 4 5 6 8 10 11 12 13 25 16 23 27 28 19 29 14 15 18
20 21 22 24 26]
References
----------
......@@ -725,9 +725,9 @@ def label_components(g, vprop=None, directed=None, attractors=False):
>>> g = gt.random_graph(100, lambda: (poisson(2), poisson(2)))
>>> comp, hist, is_attractor = gt.label_components(g, attractors=True)
>>> print(comp.a)
[14 15 14 14 14 5 14 14 18 14 14 8 14 14 13 14 14 21 14 14 7 23 10 14 14
[14 15 14 14 14 5 14 14 18 14 14 8 14 14 13 14 14 21 14 14 6 23 10 14 14
14 24 4 14 14 0 14 14 14 25 14 14 1 14 26 14 19 9 14 14 3 14 14 27 28
29 14 14 6 14 14 14 30 14 14 20 14 2 14 22 33 34 14 14 14 35 14 14 16 14
29 14 14 7 14 14 14 30 14 14 20 14 2 14 22 33 34 14 14 14 35 14 14 16 14
11 36 37 14 14 31 14 14 17 14 14 14 14 14 0 14 38 39 32 14 12 14 40 14 14]
>>> print(hist)
[ 2 1 1 1 1 1 1 1 1 1 1 1 1 1 59 1 1 1 1 1 1 1 1 1 1
......@@ -797,12 +797,12 @@ def label_largest_component(g, directed=None):
>>> g = gt.random_graph(100, lambda: poisson(1), directed=False)
>>> l = gt.label_largest_component(g)
>>> print(l.a)
[0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0
0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 1 1 0]
[0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0
0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 0]
>>> u = gt.GraphView(g, vfilt=l) # extract the largest component as a graph
>>> print(u.num_vertices())
18
22
"""
label = g.new_vertex_property("bool")
......@@ -848,18 +848,18 @@ def label_out_component(g, root):
>>> g = gt.random_graph(100, lambda: poisson(2.2), directed=False)
>>> l = gt.label_out_component(g, g.vertex(2))
>>> print(l.a)
[1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 0
1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0]
[1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1
1 1 0 0 1 1 0 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 1
1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 0 1 0]
The in-component can be obtained by reversing the graph.
>>> l = gt.label_out_component(gt.GraphView(g, reversed=True, directed=True),
... g.vertex(1))
>>> print(l.a)
[0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0
0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0]
[0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
"""
label = g.new_vertex_property("bool")
......@@ -931,17 +931,17 @@ def label_biconnected_components(g, eprop=None, vprop=None):
>>> g = gt.random_graph(100, lambda: poisson(2), directed=False)
>>> comp, art, hist = gt.label_biconnected_components(g)
>>> print(comp.a)
[35 23 35 35 32 32 35 35 1 37 32 28 32 35 32 2 32 29 35 35 13 14 34 12 17
35 35 35 35 35 3 35 35 35 35 35 35 28 28 35 33 35 19 35 35 35 35 6 35 35
24 39 35 31 35 10 9 22 32 35 4 25 26 35 35 7 35 35 35 35 35 35 36 35 35
35 32 35 0 35 35 35 32 35 28 32 35 20 30 27 18 38 16 5 15 11 28 35 8 21]
[33 34 34 34 34 34 4 20 34 34 18 34 34 34 34 34 15 34 34 34 28 34 34 34 34
34 34 34 34 34 34 11 14 34 34 34 3 34 34 34 34 34 34 34 34 27 34 34 7 10
34 34 34 34 34 24 25 34 6 35 34 13 21 30 31 12 5 34 1 32 34 34 26 34 16
34 34 23 34 34 34 34 34 36 34 34 34 34 34 29 22 17 0 2 8 37 34 38 9 19]
>>> print(art.a)
[1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 1 0 0 1 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0
0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 1 0 0 1 1 0 0 0 0 0 1 0
1 0 1 1 0 0 0 0 1 0 0 1 0 1 1 1 0 0 0 0 0 0 0 1 0 0]
[1 0 1 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 1 1 0 0 1 0 1 0
1 1 0 0 0 1 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 1
1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0]
>>> print(hist)
[ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 5 1 1 1 10 1 1 48 1 1 1 1]
1 1 1 1 1 1 1 1 1 62 1 1 1 1]
"""
if vprop is None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment