Skip to content

Commit

Permalink
Some reformat and compiled docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Rey committed Jul 24, 2023
1 parent f2dfa59 commit d4c0c9b
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 23 deletions.
38 changes: 25 additions & 13 deletions docs/_modules/pabutools/tiebreaking.html
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ <h1>Source code for pabutools.tiebreaking</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">func</span> <span class="o">=</span> <span class="n">func</span>

<div class="viewcode-block" id="TieBreakingRule.order"><a class="viewcode-back" href="../../reference/tiebreaking.html#pabutools.tiebreaking.TieBreakingRule.order">[docs]</a> <span class="k">def</span> <span class="nf">order</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">instance</span><span class="p">:</span> <span class="n">Instance</span><span class="p">,</span>
<span class="n">profile</span><span class="p">:</span> <span class="n">Profile</span><span class="p">,</span>
<span class="n">projects</span><span class="p">:</span> <span class="n">Iterable</span><span class="p">[</span><span class="n">Project</span><span class="p">],</span>
<span class="n">key</span><span class="p">:</span> <span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="n">Project</span><span class="p">]</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">,</span>
<span class="p">):</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">instance</span><span class="p">:</span> <span class="n">Instance</span><span class="p">,</span>
<span class="n">profile</span><span class="p">:</span> <span class="n">Profile</span><span class="p">,</span>
<span class="n">projects</span><span class="p">:</span> <span class="n">Iterable</span><span class="p">[</span><span class="n">Project</span><span class="p">],</span>
<span class="n">key</span><span class="p">:</span> <span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="n">Project</span><span class="p">]</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">[</span><span class="n">Project</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Break the ties among all the projects provided in input and returns them ordered. The tie-breaking can be</span>
<span class="sd"> based on the instance or/and on the profile.</span>
Expand All @@ -303,17 +303,17 @@ <h1>Source code for pabutools.tiebreaking</h1><div class="highlight"><pre>
<span class="sd"> list of pabutools.election.instance.Project</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="nb">sorted</span><span class="p">(</span>
<span class="nb">list</span><span class="p">(</span><span class="n">projects</span><span class="p">),</span>
<span class="n">projects</span><span class="p">,</span>
<span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">project</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">instance</span><span class="p">,</span> <span class="n">profile</span><span class="p">,</span> <span class="n">key</span><span class="p">(</span><span class="n">project</span><span class="p">)),</span>
<span class="p">)</span></div>

<div class="viewcode-block" id="TieBreakingRule.untie"><a class="viewcode-back" href="../../reference/tiebreaking.html#pabutools.tiebreaking.TieBreakingRule.untie">[docs]</a> <span class="k">def</span> <span class="nf">untie</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">instance</span><span class="p">:</span> <span class="n">Instance</span><span class="p">,</span>
<span class="n">profile</span><span class="p">:</span> <span class="n">Profile</span><span class="p">,</span>
<span class="n">projects</span><span class="p">:</span> <span class="n">Iterable</span><span class="p">[</span><span class="n">Project</span><span class="p">],</span>
<span class="n">key</span><span class="p">:</span> <span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="n">Project</span><span class="p">]</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">,</span>
<span class="p">):</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">instance</span><span class="p">:</span> <span class="n">Instance</span><span class="p">,</span>
<span class="n">profile</span><span class="p">:</span> <span class="n">Profile</span><span class="p">,</span>
<span class="n">projects</span><span class="p">:</span> <span class="n">Iterable</span><span class="p">[</span><span class="n">Project</span><span class="p">],</span>
<span class="n">key</span><span class="p">:</span> <span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="n">Project</span><span class="p">]</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Project</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Break the ties among all the projects provided in input and returns a single project. Orders the</span>
<span class="sd"> projects according to the tie-breaking rule and return the first project of the order.</span>
Expand All @@ -340,6 +340,18 @@ <h1>Source code for pabutools.tiebreaking</h1><div class="highlight"><pre>
<span class="p">)</span>
<span class="n">min_cost_tie_breaking</span> <span class="o">=</span> <span class="n">TieBreakingRule</span><span class="p">(</span><span class="k">lambda</span> <span class="n">inst</span><span class="p">,</span> <span class="n">prof</span><span class="p">,</span> <span class="n">proj</span><span class="p">:</span> <span class="n">proj</span><span class="o">.</span><span class="n">cost</span><span class="p">)</span>
<span class="n">max_cost_tie_breaking</span> <span class="o">=</span> <span class="n">TieBreakingRule</span><span class="p">(</span><span class="k">lambda</span> <span class="n">inst</span><span class="p">,</span> <span class="n">prof</span><span class="p">,</span> <span class="n">proj</span><span class="p">:</span> <span class="o">-</span><span class="n">proj</span><span class="o">.</span><span class="n">cost</span><span class="p">)</span>


<div class="viewcode-block" id="TieBreakingException"><a class="viewcode-back" href="../../reference/tiebreaking.html#pabutools.tiebreaking.TieBreakingException">[docs]</a><span class="k">class</span> <span class="nc">TieBreakingException</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Raised when a tie occurs and no tie-breaking rule is provided.&quot;&quot;&quot;</span>
<span class="k">pass</span></div>


<span class="k">def</span> <span class="nf">refuse_to_break_ties</span><span class="p">(</span><span class="n">instance</span><span class="p">:</span> <span class="n">Instance</span><span class="p">,</span> <span class="n">profile</span><span class="p">:</span> <span class="n">Profile</span><span class="p">,</span> <span class="n">project</span><span class="p">:</span> <span class="n">Project</span><span class="p">):</span>
<span class="k">raise</span> <span class="n">TieBreakingException</span><span class="p">(</span><span class="s2">&quot;A tie occurred, but no tie-breaking rule was provided.&quot;</span><span class="p">)</span>


<span class="n">refuse_tie_breaking</span> <span class="o">=</span> <span class="n">TieBreakingRule</span><span class="p">(</span><span class="n">refuse_to_break_ties</span><span class="p">)</span>
</pre></div>

</article>
Expand Down
2 changes: 2 additions & 0 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,8 @@ <h2 id="T">T</h2>
<li><a href="reference/election/instance.html#pabutools.election.instance.Project.targets">(Project attribute)</a>
</li>
</ul></li>
<li><a href="reference/tiebreaking.html#pabutools.tiebreaking.TieBreakingException">TieBreakingException</a>
</li>
<li><a href="reference/tiebreaking.html#pabutools.tiebreaking.TieBreakingRule">TieBreakingRule (class in pabutools.tiebreaking)</a>
</li>
<li><a href="reference/election/profile.html#pabutools.election.profile.approvalprofile.ApprovalMultiProfile.total">total() (ApprovalMultiProfile method)</a>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
1 change: 1 addition & 0 deletions docs/reference/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,7 @@ <h1>Reference<a class="headerlink" href="#reference" title="Permalink to this he
</li>
<li class="toctree-l1"><a class="reference internal" href="analysis/index.html">Analysis module</a></li>
<li class="toctree-l1"><a class="reference internal" href="tiebreaking.html">Tie-Breaking</a><ul>
<li class="toctree-l2"><a class="reference internal" href="tiebreaking.html#pabutools.tiebreaking.TieBreakingException"><code class="docutils literal notranslate"><span class="pre">TieBreakingException</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="tiebreaking.html#pabutools.tiebreaking.TieBreakingRule"><code class="docutils literal notranslate"><span class="pre">TieBreakingRule</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="tiebreaking.html#pabutools.tiebreaking.TieBreakingRule.func"><code class="docutils literal notranslate"><span class="pre">TieBreakingRule.func</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="tiebreaking.html#pabutools.tiebreaking.TieBreakingRule.order"><code class="docutils literal notranslate"><span class="pre">TieBreakingRule.order()</span></code></a></li>
Expand Down
Loading

0 comments on commit d4c0c9b

Please sign in to comment.