Commit f3ec0a54 authored by Tiago Peixoto's avatar Tiago Peixoto

Doctest fixes

parent 2d483063
......@@ -155,7 +155,7 @@ evidence efficiently, as we show below, using
.. testoutput:: model-evidence
Model evidence for deg_corr = True: -579.300446... (mean field), -832.245049... (Bethe)
Model evidence for deg_corr = False: -586.652245... (mean field), -737.721423... (Bethe)
Model evidence for deg_corr = False: -597.211055... (mean field), -728.704043... (Bethe)
If we consider the more accurate approximation, the outcome shows a
preference for the non-degree-corrected model.
......@@ -219,8 +219,8 @@ approach for the same network, using the nested model.
.. testoutput:: model-evidence
Model evidence for deg_corr = True: -523.722360... (mean field), -686.592569... (Bethe)
Model evidence for deg_corr = False: -516.006708... (mean field), -619.110456... (Bethe)
Model evidence for deg_corr = True: -503.011203... (mean field), -728.064049... (Bethe)
Model evidence for deg_corr = False: -518.022407... (mean field), -633.507167... (Bethe)
The results are similar: If we consider the most accurate approximation,
the non-degree-corrected model possesses the largest evidence. Note also
......
......@@ -25,8 +25,8 @@ we have
.. testoutput:: model-selection
:options: +NORMALIZE_WHITESPACE
Non-degree-corrected DL: 8524.911216...
Degree-corrected DL: 8274.075603...
Non-degree-corrected DL: 8470.198169...
Degree-corrected DL: 8273.840277...
Since it yields the smallest description length, the degree-corrected
fit should be preferred. The statistical significance of the choice can
......@@ -52,14 +52,15 @@ fits. In our particular case, we have
.. testoutput:: model-selection
:options: +NORMALIZE_WHITESPACE
ln Λ: -250.835612...
ln Λ: -196.357892...
The precise threshold that should be used to decide when to `reject a
hypothesis <https://en.wikipedia.org/wiki/Hypothesis_testing>`_ is
subjective and context-dependent, but the value above implies that the
particular degree-corrected fit is around :math:`\mathrm{e}^{251} \approx 10^{109}`
times more likely than the non-degree corrected one, and hence it can be
safely concluded that it provides a substantially better fit.
particular degree-corrected fit is around :math:`\mathrm{e}^{196}
\approx 10^{85}` times more likely than the non-degree corrected one,
and hence it can be safely concluded that it provides a substantially
better fit.
Although it is often true that the degree-corrected model provides a
better fit for many empirical networks, there are also exceptions. For
......
......@@ -363,10 +363,13 @@ done with the :meth:`~graph_tool.Graph.get_vertices`,
:meth:`~graph_tool.Graph.get_edges`,
:meth:`~graph_tool.Graph.get_out_edges`,
:meth:`~graph_tool.Graph.get_in_edges`,
:meth:`~graph_tool.Graph.get_all_edges`,
:meth:`~graph_tool.Graph.get_out_neighbors`,
:meth:`~graph_tool.Graph.get_in_neighbors`,
:meth:`~graph_tool.Graph.get_out_degrees` and
:meth:`~graph_tool.Graph.get_in_degrees` methods, which return
:meth:`~graph_tool.Graph.get_all_neighbors`,
:meth:`~graph_tool.Graph.get_out_degrees`,
:meth:`~graph_tool.Graph.get_in_degrees` and
:meth:`~graph_tool.Graph.get_total_degrees` methods, which return
:class:`numpy.ndarray` instances instead of iterators.
For example, using this interface we can get the out-degree of each node via:
......@@ -377,7 +380,7 @@ For example, using this interface we can get the out-degree of each node via:
.. testoutput::
[0 1 0 1 0 0 0 0 0 0 0 0]
[1 0 1 0 0 0 0 0 0 0 0 0]
or the sum of the product of the in and out-degrees of the endpoints of
each edge with:
......@@ -385,11 +388,13 @@ each edge with:
.. testcode::
edges = g.get_edges()
print((edges[:,0] * edges[:,1]).sum())
in_degs = g.get_in_degrees(g.get_vertices())
out_degs = g.get_out_degrees(g.get_vertices())
print((out_degs[edges[:,0]] * in_degs[edges[:,1]]).sum())
.. testoutput::
6
2
.. _sec_property_maps:
......
......@@ -533,7 +533,7 @@ def central_point_dominance(g, betweenness):
>>> g = gt.GraphView(g, vfilt=gt.label_largest_component(g))
>>> vp, ep = gt.betweenness(g)
>>> print(gt.central_point_dominance(g, vp))
0.11610685614...
0.105683...
References
----------
......@@ -619,8 +619,6 @@ def eigenvector(g, weight=None, vprop=None, epsilon=1e-6, max_iter=None):
>>> w = g.new_edge_property("double")
>>> w.a = np.random.random(len(w.a)) * 42
>>> ee, x = gt.eigenvector(g, w)
>>> print(ee)
724.302745...
>>> gt.graph_draw(g, pos=g.vp["pos"], vertex_fill_color=x,
... vertex_size=gt.prop_to_size(x, mi=5, ma=15),
... vcmap=matplotlib.cm.gist_heat,
......@@ -1122,8 +1120,6 @@ def trust_transitivity(g, trust_map, source=None, target=None, vprop=None):
>>> g = gt.Graph(g, prune=True)
>>> w = g.new_edge_property("double")
>>> w.a = np.random.random(len(w.a))
>>> g.vp["label"][g.vertex(42)]
'blogforamerica.com'
>>> t = gt.trust_transitivity(g, w, source=g.vertex(42))
>>> gt.graph_draw(g, pos=g.vp["pos"], vertex_fill_color=t,
... vertex_size=gt.prop_to_size(t, mi=5, ma=15),
......
......@@ -830,16 +830,16 @@ def max_cliques(g):
... print(c)
... if i == 9:
... break
[ 0 1434 1244]
[ 0 643 433 1244]
[ 0 20 1244]
[ 0 640 1130 366 567]
[ 0 640 322 67 54 154]
[ 0 640 67 114 54 154]
[ 0 640 322 240 84 54 154]
[ 0 640 433 114 84 54 154]
[ 0 640 641 20 54 154]
[ 0 640 322 20 54 154]
[513 4]
[ 4 720]
[ 4 719 1436]
[736 5]
[453 6]
[ 7 263 39 753 179 180]
[ 7 263 39 179 603]
[ 7 263 392 39 753 180 277 223]
[ 7 263 392 39 180 277 571 223]
[ 7 263 39 603 223]
References
......
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