Skip to content

Commit

Permalink
Deploying to main from @ pyt-team/TopoNetX@60ddcc7 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
ffl096 committed Dec 11, 2024
1 parent 9b0be8b commit 1d80fe1
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 14 deletions.
Binary file modified toponetx/.doctrees/environment.pickle
Binary file not shown.
16 changes: 7 additions & 9 deletions toponetx/_modules/toponetx/classes/cell_complex.html
Original file line number Diff line number Diff line change
Expand Up @@ -1769,18 +1769,16 @@ <h1>Source code for toponetx.classes.cell_complex</h1><div class="highlight"><pr
<span class="sd"> &gt;&gt;&gt; print(CC.cells)</span>
<span class="sd"> &gt;&gt;&gt; CC.remove_equivalent_cells()</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># delete all cells that are added multiple times</span>
<span class="k">for</span> <span class="n">cell</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cells</span><span class="o">.</span><span class="n">_cells</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cells</span><span class="o">.</span><span class="n">_cells</span><span class="p">[</span><span class="n">cell</span><span class="p">])</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cells</span><span class="o">.</span><span class="n">_cells</span><span class="p">[</span><span class="n">cell</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())[</span><span class="mi">1</span><span class="p">:]:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_delete_cell</span><span class="p">(</span><span class="n">cell</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span>

<span class="n">equiv_classes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cell_equivalence_class</span><span class="p">()</span>
<span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cells</span><span class="p">):</span>
<span class="k">if</span> <span class="n">c</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">equiv_classes</span><span class="p">:</span>
<span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cells</span><span class="o">.</span><span class="n">_cells</span><span class="p">[</span><span class="n">c</span><span class="o">.</span><span class="n">elements</span><span class="p">]</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">d</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_delete_cell</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">d_c</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">d_c</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">d</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
<span class="k">break</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_delete_cell</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span></div>
<span class="bp">self</span><span class="o">.</span><span class="n">_delete_cell</span><span class="p">(</span><span class="n">c</span><span class="p">)</span></div>


<div class="viewcode-block" id="CellComplex.is_insertable_cycle">
Expand Down
38 changes: 38 additions & 0 deletions toponetx/_modules/toponetx/classes/complex.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,44 @@ <h1>Source code for toponetx.classes.complex</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">_attributes</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">kwargs</span><span class="p">)</span></div>


<span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Return True if the given atom is equal to this atom.</span>

<span class="sd"> Atoms are considered equal if they have the same elements but may have</span>
<span class="sd"> different attributes.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> other : Any</span>
<span class="sd"> The atom to compare.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> bool</span>
<span class="sd"> Returns `True` if the given atom is equal to this atom and `False` otherwise.</span>

<span class="sd"> Example</span>
<span class="sd"> -------</span>
<span class="sd"> &gt;&gt;&gt; s1 = tnx.Simplex((1, 2), weight=1)</span>
<span class="sd"> &gt;&gt;&gt; s2 = tnx.Simplex((1, 2), weight=2)</span>
<span class="sd"> &gt;&gt;&gt; s3 = tnx.Simplex((1, 2, 3))</span>
<span class="sd"> &gt;&gt;&gt; s1 == s2</span>
<span class="sd"> True</span>
<span class="sd"> &gt;&gt;&gt; s1 == s3</span>
<span class="sd"> False</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">type</span><span class="p">(</span><span class="n">other</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">elements</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">elements</span>

<span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">int</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Return the hash of the atom.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> int</span>
<span class="sd"> The hash of the atom.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="nb">hash</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">elements</span><span class="p">)</span>

<span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">int</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Return the number of elements in the atom.</span>

Expand Down
2 changes: 1 addition & 1 deletion toponetx/_modules/toponetx/classes/path_complex.html
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ <h1>Source code for toponetx.classes.path_complex</h1><div class="highlight"><pr
<span class="n">tmp_paths</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">tuple</span><span class="p">(</span><span class="n">path</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span> <span class="c1"># path is a Path object</span>
<span class="n">tmp_paths</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_paths_from</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">tmp_paths</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_paths_from</span><span class="p">(</span><span class="n">tmp_paths</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">paths</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
<span class="s2">&quot;Input paths must be a graph or an iterable of paths as lists or tuples.&quot;</span>
Expand Down
9 changes: 5 additions & 4 deletions toponetx/_modules/toponetx/classes/reportviews.html
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,14 @@ <h1>Source code for toponetx.classes.reportviews</h1><div class="highlight"><pre
<span class="k">class</span> <span class="nc">CellView</span><span class="p">(</span><span class="n">AtomView</span><span class="p">[</span><span class="n">Cell</span><span class="p">]):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;A CellView class for cells of a CellComplex.&quot;&quot;&quot;</span>

<span class="c1"># Dictionary to hold cells, with keys being the tuple that defines the cell, and</span>
<span class="c1"># values being dictionaries of cell objects with different attributes</span>
<span class="n">_cells</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">tuple</span><span class="p">[</span><span class="n">Hashable</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Cell</span><span class="p">]]</span>

<div class="viewcode-block" id="CellView.__init__">
<a class="viewcode-back" href="../../../api/generated/toponetx.CellView.html#toponetx.CellView.__init__">[docs]</a>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="c1"># Initialize a dictionary to hold cells, with keys being the tuple</span>
<span class="c1"># that defines the cell, and values being dictionaries of cell objects</span>
<span class="c1"># with different attributes</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_cells</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">tuple</span><span class="p">[</span><span class="n">Hashable</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Cell</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span></div>
<span class="bp">self</span><span class="o">.</span><span class="n">_cells</span> <span class="o">=</span> <span class="p">{}</span></div>


<span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cell</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">dict</span><span class="p">[</span><span class="n">Hashable</span><span class="p">,</span> <span class="n">Any</span><span class="p">]:</span>
Expand Down

0 comments on commit 1d80fe1

Please sign in to comment.