Skip to content

Commit

Permalink
rebuilt docs
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudon committed Apr 29, 2024
1 parent de5951e commit c126ef7
Show file tree
Hide file tree
Showing 22 changed files with 637 additions and 66 deletions.
1 change: 1 addition & 0 deletions _modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<li class="toctree-l1"><a class="reference internal" href="../constructors.html">Constructors module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../app.html">The pygenstability cli</a></li>
<li class="toctree-l1"><a class="reference internal" href="../plotting.html">Plotting module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dataclustering.html">DataClustering module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../optimal_scales.html">Optimal scales module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../io.html">I/O module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../examples/example.html">Example: Markov Stability with PyGenStability</a></li>
Expand Down
17 changes: 9 additions & 8 deletions _modules/pygenstability/constructors.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../constructors.html">Constructors module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../app.html">The pygenstability cli</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../plotting.html">Plotting module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dataclustering.html">DataClustering module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../optimal_scales.html">Optimal scales module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../io.html">I/O module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../examples/example.html">Example: Markov Stability with PyGenStability</a></li>
Expand Down Expand Up @@ -210,6 +211,7 @@ <h1>Source code for pygenstability.constructors</h1><div class="highlight"><pre>
<span class="sd">:math:`\boldsymbol{1}` is the vector of ones, and we denote the diagonal degree matrix by</span>
<span class="sd">:math:`D=\mathrm{diag}(d)`.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">sys</span>

Expand All @@ -219,9 +221,8 @@ <h1>Source code for pygenstability.constructors</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">threadpoolctl</span> <span class="kn">import</span> <span class="n">threadpool_limits</span>

<span class="n">L</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<span class="n">_USE_CACHE</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">THRESHOLD</span> <span class="o">=</span> <span class="mf">1e-8</span>
<span class="n">DTYPE</span> <span class="o">=</span> <span class="s2">&quot;float128&quot;</span>
<span class="n">_DTYPE</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">float64</span>


<div class="viewcode-block" id="load_constructor"><a class="viewcode-back" href="../../constructors.html#pygenstability.constructors.load_constructor">[docs]</a><span class="k">def</span> <span class="nf">load_constructor</span><span class="p">(</span><span class="n">constructor</span><span class="p">,</span> <span class="n">graph</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
Expand Down Expand Up @@ -302,7 +303,7 @@ <h1>Source code for pygenstability.constructors</h1><div class="highlight"><pre>
<span class="k">def</span> <span class="nf">_get_exp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scale</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Compute matrix exponential at a given scale.&quot;&quot;&quot;</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exp_comp_mode</span> <span class="o">==</span> <span class="s2">&quot;expm&quot;</span><span class="p">:</span>
<span class="n">exp</span> <span class="o">=</span> <span class="n">sp</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">expm</span><span class="p">(</span><span class="o">-</span><span class="n">scale</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">partial_quality_matrix</span><span class="o">.</span><span class="n">toarray</span><span class="p">()</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">DTYPE</span><span class="p">))</span>
<span class="n">exp</span> <span class="o">=</span> <span class="n">sp</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">expm</span><span class="p">(</span><span class="o">-</span><span class="n">scale</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">partial_quality_matrix</span><span class="o">.</span><span class="n">toarray</span><span class="p">()</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">_DTYPE</span><span class="p">))</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exp_comp_mode</span> <span class="o">==</span> <span class="s2">&quot;spectral&quot;</span><span class="p">:</span>
<span class="n">lambdas</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">vinv</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">spectral_decomp</span>
<span class="n">exp</span> <span class="o">=</span> <span class="n">v</span> <span class="o">@</span> <span class="n">np</span><span class="o">.</span><span class="n">diag</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">scale</span> <span class="o">*</span> <span class="n">lambdas</span><span class="p">))</span> <span class="o">@</span> <span class="n">vinv</span>
Expand Down Expand Up @@ -348,7 +349,7 @@ <h1>Source code for pygenstability.constructors</h1><div class="highlight"><pre>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_spectral_gap</span><span class="p">:</span>
<span class="n">laplacian</span> <span class="o">=</span> <span class="n">sp</span><span class="o">.</span><span class="n">csgraph</span><span class="o">.</span><span class="n">laplacian</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">graph</span><span class="p">,</span> <span class="n">normed</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">spectral_gap</span> <span class="o">=</span> <span class="n">_get_spectral_gap</span><span class="p">(</span><span class="n">laplacian</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">partial_quality_matrix</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">graph</span> <span class="o">/</span> <span class="n">degrees</span><span class="o">.</span><span class="n">sum</span><span class="p">())</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">DTYPE</span><span class="p">)</span></div>
<span class="bp">self</span><span class="o">.</span><span class="n">partial_quality_matrix</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">graph</span> <span class="o">/</span> <span class="n">degrees</span><span class="o">.</span><span class="n">sum</span><span class="p">())</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">_DTYPE</span><span class="p">)</span></div>

<span class="nd">@_limit_numpy</span>
<span class="k">def</span> <span class="nf">_get_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scale</span><span class="p">):</span>
Expand Down Expand Up @@ -382,7 +383,7 @@ <h1>Source code for pygenstability.constructors</h1><div class="highlight"><pre>
<span class="n">_check_total_degree</span><span class="p">(</span><span class="n">degrees</span><span class="p">)</span>
<span class="n">laplacian</span> <span class="o">/=</span> <span class="n">degrees</span><span class="o">.</span><span class="n">mean</span><span class="p">()</span>
<span class="n">pi</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">graph</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">graph</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">partial_null_model</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">pi</span><span class="p">,</span> <span class="n">pi</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="n">DTYPE</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">partial_null_model</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">pi</span><span class="p">,</span> <span class="n">pi</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="n">_DTYPE</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_spectral_gap</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">spectral_gap</span> <span class="o">=</span> <span class="n">_get_spectral_gap</span><span class="p">(</span><span class="n">laplacian</span><span class="p">)</span>

Expand Down Expand Up @@ -423,7 +424,7 @@ <h1>Source code for pygenstability.constructors</h1><div class="highlight"><pre>
<span class="n">normed_laplacian</span> <span class="o">=</span> <span class="n">sp</span><span class="o">.</span><span class="n">diags</span><span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="n">degrees</span><span class="p">)</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">laplacian</span><span class="p">)</span>

<span class="n">pi</span> <span class="o">=</span> <span class="n">degrees</span> <span class="o">/</span> <span class="n">degrees</span><span class="o">.</span><span class="n">sum</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">partial_null_model</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">pi</span><span class="p">,</span> <span class="n">pi</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="n">DTYPE</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">partial_null_model</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">pi</span><span class="p">,</span> <span class="n">pi</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="n">_DTYPE</span><span class="p">)</span>

<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_spectral_gap</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">spectral_gap</span> <span class="o">=</span> <span class="n">_get_spectral_gap</span><span class="p">(</span><span class="n">normed_laplacian</span><span class="p">)</span>
Expand Down Expand Up @@ -452,7 +453,7 @@ <h1>Source code for pygenstability.constructors</h1><div class="highlight"><pre>
<span class="sd"> positive and negative degree vectors.</span>

<span class="sd"> References:</span>
<span class="sd"> .. [1] Gómez, S., Jensen, P., &amp; Arenas, A. (2009). Analysis of community structure in</span>
<span class="sd"> .. [1] Gomez, S., Jensen, P., &amp; Arenas, A. (2009). Analysis of community structure in</span>
<span class="sd"> networks of correlated data. Physical Review E, 80(1), 016114.</span>
<span class="sd"> &quot;&quot;&quot;</span>

Expand Down Expand Up @@ -507,7 +508,7 @@ <h1>Source code for pygenstability.constructors</h1><div class="highlight"><pre>
<span class="n">degrees_abs</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="nb">abs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">graph</span><span class="p">)</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span><span class="o">.</span><span class="n">flatten</span><span class="p">()</span>
<span class="n">laplacian</span> <span class="o">=</span> <span class="n">sp</span><span class="o">.</span><span class="n">diags</span><span class="p">(</span><span class="n">degrees_abs</span><span class="p">)</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">graph</span>

<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exp_comp_mode</span> <span class="o">==</span> <span class="s2">&quot;spectral&quot;</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exp_comp_mode</span> <span class="o">==</span> <span class="s2">&quot;spectral&quot;</span><span class="p">:</span> <span class="c1"># pragma: no cover</span>
<span class="bp">self</span><span class="o">.</span><span class="n">spectral_decomp</span> <span class="o">=</span> <span class="n">_compute_spectral_decomp</span><span class="p">(</span><span class="n">laplacian</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exp_comp_mode</span> <span class="o">==</span> <span class="s2">&quot;expm&quot;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">partial_quality_matrix</span> <span class="o">=</span> <span class="n">laplacian</span>
Expand Down
2 changes: 2 additions & 0 deletions _modules/pygenstability/io.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../constructors.html">Constructors module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../app.html">The pygenstability cli</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../plotting.html">Plotting module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dataclustering.html">DataClustering module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../optimal_scales.html">Optimal scales module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../io.html">I/O module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../examples/example.html">Example: Markov Stability with PyGenStability</a></li>
Expand Down Expand Up @@ -196,6 +197,7 @@
<article role="main">
<h1>Source code for pygenstability.io</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;I/O functions.&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">pickle</span>


Expand Down
6 changes: 4 additions & 2 deletions _modules/pygenstability/optimal_scales.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../constructors.html">Constructors module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../app.html">The pygenstability cli</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../plotting.html">Plotting module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dataclustering.html">DataClustering module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../optimal_scales.html">Optimal scales module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../io.html">I/O module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../examples/example.html">Example: Markov Stability with PyGenStability</a></li>
Expand Down Expand Up @@ -196,6 +197,7 @@
<article role="main">
<h1>Source code for pygenstability.optimal_scales</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;Detect optimal scales from a scale scan.&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
<span class="kn">from</span> <span class="nn">numpy.lib.stride_tricks</span> <span class="kn">import</span> <span class="n">as_strided</span>
Expand Down Expand Up @@ -256,8 +258,8 @@ <h1>Source code for pygenstability.optimal_scales</h1><div class="highlight"><pr
<span class="sd"> result dictionary with two new keys: &#39;selected_partitions&#39; and &#39;block_detection_curve&#39;</span>

<span class="sd"> References:</span>
<span class="sd"> .. [1] D. J. Schindler, J. Clarke, and M. Barahona, Multiscale Mobility Patterns and</span>
<span class="sd"> the Restriction of Human Movement, *arXiv:2201.06323*, 2023</span>
<span class="sd"> .. [1] D. J. Schindler, J. Clarke, and M. Barahona, &#39;Multiscale Mobility Patterns and</span>
<span class="sd"> the Restriction of Human Movement&#39;, *arXiv:2201.06323*, 2023</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># get NVI(t) and NVI(t,t&#39;)</span>
<span class="n">nvi_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">results</span><span class="p">[</span><span class="s2">&quot;NVI&quot;</span><span class="p">])</span>
Expand Down
Loading

0 comments on commit c126ef7

Please sign in to comment.