Commit ab4b82b5 by Tiago Peixoto

### Update docstring tests

parent e39910a5
Pipeline #449 failed with stage
in 820 minutes and 26 seconds
 ... ... @@ -245,9 +245,9 @@ Therefore, we can compute the posterior odds ratio between both models as: .. testoutput:: food-web :options: +NORMALIZE_WHITESPACE ln Λ: -70.145685... ln Λ: -24.246389... A value of :math:\Lambda \approx \mathrm{e}^{-70} \approx 10^{-30} in A value of :math:\Lambda \approx \mathrm{e}^{-24} \approx 10^{-10} in favor the exponential model indicates that the log-normal model does not provide a better fit for this particular data. Based on this, we conclude that the exponential model should be preferred in this case. ... ...
 ... ... @@ -134,7 +134,7 @@ illustrate its use with the neural network of the C. elegans .. testsetup:: celegans gt.seed_rng(47) gt.seed_rng(51) .. testcode:: celegans ... ... @@ -186,9 +186,9 @@ which shows the number of nodes and groups in all levels: .. testoutput:: celegans l: 0, N: 297, B: 17 l: 1, N: 17, B: 9 l: 2, N: 9, B: 3 l: 0, N: 297, B: 16 l: 1, N: 16, B: 8 l: 2, N: 8, B: 3 l: 3, N: 3, B: 1 The hierarchical levels themselves are represented by individual ... ... @@ -203,10 +203,10 @@ The hierarchical levels themselves are represented by individual .. testoutput:: celegans , at 0x...> , at 0x...> , at 0x...> , at 0x...> , at 0x...> , at 0x...> , at 0x...> , at 0x...> This means that we can inspect the hierarchical partition just as before: ... ... @@ -221,6 +221,6 @@ This means that we can inspect the hierarchical partition just as before: .. testoutput:: celegans 7 0 2 1 0
 ... ... @@ -154,8 +154,8 @@ evidence efficiently, as we show below, using .. testoutput:: model-evidence Model evidence for deg_corr = True: -569.590426... (mean field), -817.788531... (Bethe) Model evidence for deg_corr = False: -587.028530... (mean field), -736.990655... (Bethe) 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) 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: -551.228195... (mean field), -740.460493... (Bethe) Model evidence for deg_corr = False: -544.660366... (mean field), -649.135026... (Bethe) Model evidence for deg_corr = True: -555.768070... (mean field), -731.501041... (Bethe) Model evidence for deg_corr = False: -544.346500... (mean field), -630.951518... (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: 8456.994339... Degree-corrected DL: 8233.850036... Non-degree-corrected DL: 8524.911216... Degree-corrected DL: 8274.075603... Since it yields the smallest description length, the degree-corrected fit should be preferred. The statistical significance of the choice can ... ... @@ -52,12 +52,12 @@ fits. In our particular case, we have .. testoutput:: model-selection :options: +NORMALIZE_WHITESPACE ln Λ: -223.144303... ln Λ: -250.835612... The precise threshold that should be used to decide when to reject a hypothesis _ is subjective and context-dependent, but the value above implies that the particular degree-corrected fit is around :math:\mathrm{e}^{233} \approx 10^{96} 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. ... ... @@ -79,11 +79,11 @@ example, for the American football network above, we have: .. testoutput:: model-selection :options: +NORMALIZE_WHITESPACE Non-degree-corrected DL: 1734.814739... Non-degree-corrected DL: 1733.525685... Degree-corrected DL: 1780.576716... ln Λ: -45.761977... ln Λ: -47.051031... Hence, with a posterior odds ratio of :math:\Lambda \approx \mathrm{e}^{-45} \approx 10^{-19} in favor of the non-degree-corrected model, it seems like the Hence, with a posterior odds ratio of :math:\Lambda \approx \mathrm{e}^{-47} \approx 10^{-20}` in favor of the non-degree-corrected model, we conclude that the degree-corrected variant is an unnecessarily complex description for this network.
 ... ... @@ -185,9 +185,9 @@ Which yields the following output: .. testoutput:: measured Posterior probability of edge (11, 36): 0.801980... Posterior probability of non-edge (15, 73): 0.097309... Estimated average local clustering: 0.572154 ± 0.004853... Posterior probability of edge (11, 36): 0.812881... Posterior probability of non-edge (15, 73): 0.160516... Estimated average local clustering: 0.57309 ± 0.005985... We have a successful reconstruction, where both ambiguous adjacency matrix entries are correctly recovered. The value for the average ... ... @@ -306,9 +306,9 @@ Which yields: .. testoutput:: measured Posterior probability of edge (11, 36): 0.790179... Posterior probability of non-edge (15, 73): 0.109010... Estimated average local clustering: 0.572504 ± 0.005453... Posterior probability of edge (11, 36): 0.693369... Posterior probability of non-edge (15, 73): 0.170517... Estimated average local clustering: 0.570545 ± 0.006892... The results are very similar to the ones obtained with the uniform model in this case, but can be quite different in situations where a large ... ... @@ -434,9 +434,9 @@ The above yields the output: .. testoutput:: uncertain Posterior probability of edge (11, 36): 0.950495... Posterior probability of non-edge (15, 73): 0.067406... Estimated average local clustering: 0.552333 ± 0.019183... Posterior probability of edge (11, 36): 0.881188... Posterior probability of non-edge (15, 73): 0.043004... Estimated average local clustering: 0.557825 ± 0.014038... The reconstruction is accurate, despite the two ambiguous entries having the same measurement probability. The reconstructed network is visualized below. ... ...
This diff is collapsed.
 ... ... @@ -1837,9 +1837,9 @@ class Graph(object): -------- >>> g = gt.random_graph(6, lambda: 1, directed=False) >>> g.get_edges() array([[2, 1, 2], [3, 4, 0], [5, 0, 1]], dtype=uint64) array([[0, 3, 2], [1, 4, 1], [2, 5, 0]], dtype=uint64) """ edges = libcore.get_edge_list(self.__graph) E = edges.shape[0] // 3 ... ...
 ... ... @@ -112,16 +112,10 @@ def local_clustering(g, prop=None, undirected=True): Examples -------- .. testcode:: :hide: np.random.seed(42) gt.seed_rng(42) >>> g = gt.random_graph(1000, lambda: (5,5)) >>> g = gt.collection.data["karate"] >>> clust = gt.local_clustering(g) >>> print(gt.vertex_average(g, clust)) (0.008177777777777779, 0.00042080229075093...) (0.5706384782..., 0.05869813676...) References ---------- ... ... @@ -174,15 +168,9 @@ def global_clustering(g): Examples -------- .. testcode:: :hide: np.random.seed(42) gt.seed_rng(42) >>> g = gt.random_graph(1000, lambda: (5,5)) >>> g = gt.collection.data["karate"] >>> print(gt.global_clustering(g)) (0.008177777777777779, 0.0004212235142651...) (0.2556818181..., 0.06314746595...) References ---------- ... ... @@ -252,22 +240,16 @@ def extended_clustering(g, props=None, max_depth=3, undirected=False): Examples -------- .. testcode:: :hide: np.random.seed(42) gt.seed_rng(42) >>> g = gt.random_graph(1000, lambda: (5,5)) >>> g = gt.collection.data["karate"] >>> clusts = gt.extended_clustering(g, max_depth=5) >>> for i in range(0, 5): ... print(gt.vertex_average(g, clusts[i])) ... (0.0050483333333333335, 0.0004393940240073...) (0.024593787878787878, 0.0009963004021144...) (0.11238924242424242, 0.001909615401971...) (0.40252272727272725, 0.003113987400030...) (0.43629378787878786, 0.003144159256565...) (0.5706384782076..., 0.05869813676256...) (0.3260389360735..., 0.04810773205917...) (0.0530678759917..., 0.01513061504691...) (0.0061658977316..., 0.00310690511463...) (0.0002162629757..., 0.00021305890271...) References ---------- ... ... @@ -349,9 +331,9 @@ def motifs(g, k, p=1.0, motif_list=None, return_maps=False): >>> g = gt.random_graph(1000, lambda: (5,5)) >>> motifs, counts = gt.motifs(gt.GraphView(g, directed=False), 4) >>> print(len(motifs)) 18 11 >>> print(counts) [115557, 390005, 627, 700, 1681, 2815, 820, 12, 27, 44, 15, 7, 12, 4, 6, 1, 2, 1] [116386, 392916, 443, 507, 2574, 1124, 741, 5, 5, 8, 2] References ---------- ... ... @@ -520,9 +502,9 @@ def motif_significance(g, k, n_shuffles=100, p=1.0, motif_list=None, >>> g = gt.random_graph(100, lambda: (3,3)) >>> motifs, zscores = gt.motif_significance(g, 3) >>> print(len(motifs)) 11 12 >>> print(zscores) [0.22728646681107012, 0.21409572051644973, 0.007022040788902111, 0.5872141967123348, -0.37770179603294357, -0.3484733504783734, 0.8861811801325502, -0.08, -0.2, -0.38, -0.2] [2.59252643351441, 2.5966529814390387, 2.3459237708258587, -1.0829180621127024, -1.3368754665984663, -2.33027728409781, -3.055817397993647, -0.1, -0.15, -0.19, -0.4, -0.01] References ---------- ... ...
 ... ... @@ -2067,7 +2067,7 @@ class BlockState(object): ... ret = state.mcmc_sweep(niter=10) ... pe = state.collect_edge_marginals(pe) >>> gt.bethe_entropy(g, pe)[0] -0.901611... 12.204791... """ if p is None: ... ... @@ -2124,7 +2124,7 @@ class BlockState(object): ... ret = state.mcmc_sweep(niter=10) ... pv = state.collect_vertex_marginals(pv) >>> gt.mf_entropy(g, pv) 26.887021... 16.904653... >>> gt.graph_draw(g, pos=g.vp["pos"], vertex_shape="pie", ... vertex_pie_fractions=pv, output="polbooks_blocks_soft_B4.pdf") <...> ... ... @@ -2193,8 +2193,7 @@ class BlockState(object): ... ret = state.mcmc_sweep(niter=10) ... ph = state.collect_partition_histogram(ph) >>> gt.microstate_entropy(ph) 129.330077... 137.024741... """ if h is None: ... ...
 ... ... @@ -374,7 +374,7 @@ def incidence(g, vindex=None, eindex=None): >>> print(m.todense()) [[-1. -1. 0. ... 0. 0. 0.] [ 0. 0. 0. ... 0. 0. 0.] [ 0. 0. 0. ... 0. 0. 0.] [ 1. 0. 0. ... 0. 0. 0.] ... [ 0. 0. -1. ... 0. 0. 0.] [ 0. 0. 0. ... 0. 0. 0.] ... ...
 ... ... @@ -113,8 +113,8 @@ def vertex_hist(g, deg, bins=[0, 1], float_count=True): >>> from numpy.random import poisson >>> g = gt.random_graph(1000, lambda: (poisson(5), poisson(5))) >>> print(gt.vertex_hist(g, "out")) [array([ 7., 33., 91., 145., 165., 164., 152., 115., 62., 29., 28., 6., 1., 1., 0., 1.]), array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [array([ 5., 32., 85., 148., 152., 182., 160., 116., 53., 25., 23., 13., 3., 2., 1.]), array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], dtype=uint64)] """ ... ... @@ -178,7 +178,7 @@ def edge_hist(g, eprop, bins=[0, 1], float_count=True): >>> eprop = g.new_edge_property("double") >>> eprop.get_array()[:] = random(g.num_edges()) >>> print(gt.edge_hist(g, eprop, linspace(0, 1, 11))) [array([501., 441., 478., 480., 506., 494., 507., 535., 499., 559.]), array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ])] [array([485., 538., 502., 505., 474., 497., 544., 465., 492., 498.]), array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ])] """ ... ... @@ -232,7 +232,7 @@ def vertex_average(g, deg): >>> from numpy.random import poisson >>> g = gt.random_graph(1000, lambda: (poisson(5), poisson(5))) >>> print(gt.vertex_average(g, "in")) (4.96, 0.0679882342762334) (4.986, 0.07323799560337517) """ if isinstance(deg, PropertyMap) and "string" in deg.value_type(): ... ... @@ -294,7 +294,7 @@ def edge_average(g, eprop): >>> eprop = g.new_edge_property("double") >>> eprop.get_array()[:] = random(g.num_edges()) >>> print(gt.edge_average(g, eprop)) (0.49888156584192045, 0.004096739923418754) (0.5027850372071281, 0.004073940886690715) """ if "string" in eprop.value_type(): ... ... @@ -427,10 +427,10 @@ def distance_histogram(g, weight=None, bins=[0, 1], samples=None, >>> g = gt.random_graph(100, lambda: (3, 3)) >>> hist = gt.distance_histogram(g) >>> print(hist) [array([ 0., 300., 880., 2269., 3974., 2358., 119.]), array([0, 1, 2, 3, 4, 5, 6, 7], dtype=uint64)] [array([ 0., 300., 862., 2195., 3850., 2518., 175.]), array([0, 1, 2, 3, 4, 5, 6, 7], dtype=uint64)] >>> hist = gt.distance_histogram(g, samples=10) >>> print(hist) [array([ 0., 30., 87., 223., 394., 239., 17.]), array([0, 1, 2, 3, 4, 5, 6, 7], dtype=uint64)] [array([ 0., 30., 86., 213., 378., 262., 21.]), array([0, 1, 2, 3, 4, 5, 6, 7], dtype=uint64)] """ if samples is not None: ... ...
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!