Skip to content

Commit

Permalink
Docs++
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Rey committed Apr 25, 2024
1 parent 4d75df9 commit 7d01f6a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
9 changes: 5 additions & 4 deletions docs/_modules/pabutools/visualisation/visualisation.html
Original file line number Diff line number Diff line change
Expand Up @@ -793,16 +793,16 @@ <h1>Source code for pabutools.visualisation.visualisation</h1><div class="highli

<div class="viewcode-block" id="GreedyWelfareVisualiser.render">
<a class="viewcode-back" href="../../../reference/visualisation/index.html#pabutools.visualisation.GreedyWelfareVisualiser.render">[docs]</a>
<span class="k">def</span> <span class="nf">render</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output_folder_path</span><span class="p">,</span> <span class="n">output_filename</span><span class="o">=</span><span class="s2">&quot;greedy_explanation.html&quot;</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">render</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output_folder_path</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Render the visualisation.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> output_folder_path : str</span>
<span class="sd"> The path to the folder where the visualisation will be saved.</span>
<span class="sd"> output_filename : str, optional</span>
<span class="sd"> The name of the file. The default is &quot;greedy_explanation.html&quot;.</span>
<span class="sd"> name : str, optional</span>
<span class="sd"> The prefix of the output files. The default is &quot;&quot;.</span>
<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> None</span>
Expand All @@ -825,10 +825,11 @@ <h1>Source code for pabutools.visualisation.visualisation</h1><div class="highli
<span class="n">spent</span><span class="o">=</span><span class="n">total_cost</span><span class="p">(</span><span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">instance</span> <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">outcome</span><span class="p">),</span>
<span class="n">budget</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">instance</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">&quot;budget&quot;</span><span class="p">],</span>
<span class="n">total_votes</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">instance</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">&quot;num_votes&quot;</span><span class="p">],</span>
<span class="n">name</span><span class="o">=</span><span class="n">name</span>
<span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">output_folder_path</span><span class="p">):</span>
<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">output_folder_path</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">output_folder_path</span><span class="si">}</span><span class="s2">/</span><span class="si">{</span><span class="n">output_filename</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">,</span> <span class="s2">&quot;w&quot;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">&quot;utf-8&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">o</span><span class="p">:</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">output_folder_path</span><span class="si">}</span><span class="s2">/</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">_round_analysis.html&quot;</span><span class="p">,</span> <span class="s2">&quot;w&quot;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">&quot;utf-8&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">o</span><span class="p">:</span>
<span class="n">o</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">round_analysis_page_output</span><span class="p">)</span></div>
</div>

Expand Down
6 changes: 3 additions & 3 deletions docs/_sources/usage/outcomevisualisation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ generate the visualisation.
# The visualiser takes the profile, instance, and outcome as arguments
visualiser = GreedyWelfareVisualiser(profile, instance, outcome)
# output_filename is option and defaults to greedy_explanation.html
visualiser.render("./{path_to_output_file}/", output_filename="{output_filename}")
# name is optional and defaults to the empty string
visualiser.render("./{path_to_output_file}/", name="{name}")
The visualisation will be saved in the specified path as a standalone HTML file called round_analysis.html.
The visualisation will be saved in the specified path as a standalone HTML file called "{name}_round_analysis.html".

Note that the visualisation is only available for additive utility functions.

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/visualisation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,13 @@ <h2> Contents </h2>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="pabutools.visualisation.GreedyWelfareVisualiser.render">
<span class="sig-name descname"><span class="pre">render</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output_folder_path</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'greedy_explanation.html'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/pabutools/visualisation/visualisation.html#GreedyWelfareVisualiser.render"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pabutools.visualisation.GreedyWelfareVisualiser.render" title="Link to this definition">#</a></dt>
<span class="sig-name descname"><span class="pre">render</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output_folder_path</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/pabutools/visualisation/visualisation.html#GreedyWelfareVisualiser.render"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pabutools.visualisation.GreedyWelfareVisualiser.render" title="Link to this definition">#</a></dt>
<dd><p>Render the visualisation.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>output_folder_path</strong> (<em>str</em>) – The path to the folder where the visualisation will be saved.</p></li>
<li><p><strong>output_filename</strong> (<em>str</em><em>, </em><em>optional</em>) – The name of the file. The default is “greedy_explanation.html”.</p></li>
<li><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em>) – The prefix of the output files. The default is “”.</p></li>
</ul>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/usage/outcomevisualisation.html
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@ <h2>Greedy Utilitarian Welfare<a class="headerlink" href="#greedy-utilitarian-we
<span class="c1"># The visualiser takes the profile, instance, and outcome as arguments</span>
<span class="n">visualiser</span> <span class="o">=</span> <span class="n">GreedyWelfareVisualiser</span><span class="p">(</span><span class="n">profile</span><span class="p">,</span> <span class="n">instance</span><span class="p">,</span> <span class="n">outcome</span><span class="p">)</span>

<span class="c1"># output_filename is option and defaults to greedy_explanation.html</span>
<span class="n">visualiser</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="s2">&quot;./</span><span class="si">{path_to_output_file}</span><span class="s2">/&quot;</span><span class="p">,</span> <span class="n">output_filename</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{output_filename}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="c1"># name is optional and defaults to the empty string</span>
<span class="n">visualiser</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="s2">&quot;./</span><span class="si">{path_to_output_file}</span><span class="s2">/&quot;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">{name}</span><span class="s2">&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>The visualisation will be saved in the specified path as a standalone HTML file called round_analysis.html.</p>
<p>The visualisation will be saved in the specified path as a standalone HTML file called “{name}_round_analysis.html.</p>
<p>Note that the visualisation is only available for additive utility functions.</p>
<p>An example of the generated visualisation can be found
<a class="reference external" href="../outcome_vis_ex_greedy.html">here</a>.</p>
Expand Down

0 comments on commit 7d01f6a

Please sign in to comment.