Skip to content

Commit

Permalink
Add typing to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
brandones committed May 29, 2024
1 parent 74d053a commit 6be7bc7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
10 changes: 5 additions & 5 deletions docs/html/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
<span id="api"></span><h1>API<a class="headerlink" href="#module-graphpca" title="Link to this heading"></a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="graphpca.draw_graph">
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">draw_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#graphpca.draw_graph" title="Link to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">draw_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Graph</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">DiGraph</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#graphpca.draw_graph" title="Link to this definition"></a></dt>
<dd><p>Draws the input graph on two axes with lines between the nodes</p>
<p>Positions of the nodes are determined with reduce_graph, of course.</p>
<p>Positions of the nodes are determined with reduce_graph.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>nx_graph</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">nx.Graph</span></code> or <code class="xref py py-class docutils literal notranslate"><span class="pre">nx.DiGraph</span></code>) – The graph to be plotted</p>
Expand All @@ -47,7 +47,7 @@

<dl class="py function">
<dt class="sig sig-object py" id="graphpca.reduce_graph">
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#graphpca.reduce_graph" title="Link to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Graph</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">DiGraph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">ndarray</span></span></span><a class="headerlink" href="#graphpca.reduce_graph" title="Link to this definition"></a></dt>
<dd><p>Run PCA on the ETCD of the input NetworkX graph</p>
<p>The best algorithm and parameters for doing so are selected dynamically,
based on the size of the graph. A graph G with number of nodes n &lt; 50 will
Expand All @@ -67,7 +67,7 @@

<dl class="py function">
<dt class="sig sig-object py" id="graphpca.reduce_graph_efficiently">
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph_efficiently</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">add_supernode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eigendecomp_strategy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'smart'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#graphpca.reduce_graph_efficiently" title="Link to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph_efficiently</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Graph</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">DiGraph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">add_supernode</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eigendecomp_strategy</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Literal</span><span class="p"><span class="pre">[</span></span><span class="s"><span class="pre">'smart'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'sparse'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'exact'</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'smart'</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">ndarray</span></span></span><a class="headerlink" href="#graphpca.reduce_graph_efficiently" title="Link to this definition"></a></dt>
<dd><p>Run PCA on the ETCD of the input NetworkX graph</p>
<p>We skip calculating the actual ETCD for efficiency. The ETCD is given by
the Moore-Penrose pseudoinverse of the Laplacian of the input graph. The
Expand Down Expand Up @@ -120,7 +120,7 @@

<dl class="py function">
<dt class="sig sig-object py" id="graphpca.reduce_graph_naively">
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph_naively</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eigendecomp_strategy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'exact'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#graphpca.reduce_graph_naively" title="Link to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph_naively</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Graph</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">DiGraph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eigendecomp_strategy</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Literal</span><span class="p"><span class="pre">[</span></span><span class="s"><span class="pre">'exact'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'sparse'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'smart'</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'exact'</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">ndarray</span></span></span><a class="headerlink" href="#graphpca.reduce_graph_naively" title="Link to this definition"></a></dt>
<dd><p>Run PCA on the ETCD of a NetworkX graph using a slow but precise method</p>
<p>This is the method that calculates the actual ETCD. It calculates the
Moore-Penrose pseudoinverse of the Laplacian of the input graph. We return
Expand Down
10 changes: 5 additions & 5 deletions docs/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
<span id="api"></span><h1>API<a class="headerlink" href="#module-graphpca" title="Link to this heading"></a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="graphpca.draw_graph">
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">draw_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#graphpca.draw_graph" title="Link to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">draw_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Graph</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">DiGraph</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#graphpca.draw_graph" title="Link to this definition"></a></dt>
<dd><p>Draws the input graph on two axes with lines between the nodes</p>
<p>Positions of the nodes are determined with reduce_graph, of course.</p>
<p>Positions of the nodes are determined with reduce_graph.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>nx_graph</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">nx.Graph</span></code> or <code class="xref py py-class docutils literal notranslate"><span class="pre">nx.DiGraph</span></code>) – The graph to be plotted</p>
Expand All @@ -47,7 +47,7 @@

<dl class="py function">
<dt class="sig sig-object py" id="graphpca.reduce_graph">
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#graphpca.reduce_graph" title="Link to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Graph</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">DiGraph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">ndarray</span></span></span><a class="headerlink" href="#graphpca.reduce_graph" title="Link to this definition"></a></dt>
<dd><p>Run PCA on the ETCD of the input NetworkX graph</p>
<p>The best algorithm and parameters for doing so are selected dynamically,
based on the size of the graph. A graph G with number of nodes n &lt; 50 will
Expand All @@ -67,7 +67,7 @@

<dl class="py function">
<dt class="sig sig-object py" id="graphpca.reduce_graph_efficiently">
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph_efficiently</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">add_supernode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eigendecomp_strategy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'smart'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#graphpca.reduce_graph_efficiently" title="Link to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph_efficiently</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Graph</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">DiGraph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">add_supernode</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eigendecomp_strategy</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Literal</span><span class="p"><span class="pre">[</span></span><span class="s"><span class="pre">'smart'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'sparse'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'exact'</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'smart'</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">ndarray</span></span></span><a class="headerlink" href="#graphpca.reduce_graph_efficiently" title="Link to this definition"></a></dt>
<dd><p>Run PCA on the ETCD of the input NetworkX graph</p>
<p>We skip calculating the actual ETCD for efficiency. The ETCD is given by
the Moore-Penrose pseudoinverse of the Laplacian of the input graph. The
Expand Down Expand Up @@ -120,7 +120,7 @@

<dl class="py function">
<dt class="sig sig-object py" id="graphpca.reduce_graph_naively">
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph_naively</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eigendecomp_strategy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'exact'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#graphpca.reduce_graph_naively" title="Link to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">graphpca.</span></span><span class="sig-name descname"><span class="pre">reduce_graph_naively</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx_graph</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Graph</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">DiGraph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_dim</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eigendecomp_strategy</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Literal</span><span class="p"><span class="pre">[</span></span><span class="s"><span class="pre">'exact'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'sparse'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'smart'</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'exact'</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">ndarray</span></span></span><a class="headerlink" href="#graphpca.reduce_graph_naively" title="Link to this definition"></a></dt>
<dd><p>Run PCA on the ETCD of a NetworkX graph using a slow but precise method</p>
<p>This is the method that calculates the actual ETCD. It calculates the
Moore-Penrose pseudoinverse of the Laplacian of the input graph. We return
Expand Down
Loading

0 comments on commit 6be7bc7

Please sign in to comment.