Skip to content

Commit

Permalink
Merge pull request #25 from lchipchase/mes-and-greedy
Browse files Browse the repository at this point in the history
Fix page links
  • Loading branch information
Simon-Rey authored Apr 19, 2024
2 parents e3122fe + 7076553 commit 4711e27
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions docs-source/source/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
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,12 @@
<body >
<header>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="./summary.html">Summary</a>
<a class="navbar-brand" href="./{{name}}_round_analysis.html">Round Analysis<span class="sr-only">(current)</span></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="./round_analysis.html">Round By Round <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://pypi.org/project/pabutools/">Pabutools</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
<body>
<header>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand active" href="./summary.html">Summary<span class="sr-only">(current)</span></a>
<a class="navbar-brand active" href="./{{name}}_summary.html">Summary<span class="sr-only">(current)</span></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
Expand All @@ -285,7 +285,7 @@
<a class="nav-link" href="./{{name}}_round_analysis.html">Round By Round</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">Pabutools</a>
<a class="nav-link" href="https://pypi.org/project/pabutools/">Pabutools</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://equalshares.net/">MES</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="./round_analysis.html">Round By Round <span class="sr-only">(current)</span></a>
<a class="nav-link" href="./{{name}}_round_analysis.html">Round By Round <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="">Pabutools</a>
<a class="nav-link" href="https://pypi.org/project/pabutools/">Pabutools</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">MES</a>
<a class="nav-link" href="https://equalshares.net/">MES</a>
</li>
</ul>
</div>
Expand Down
9 changes: 5 additions & 4 deletions pabutools/visualisation/visualisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,16 +512,16 @@ def _calculate(self):
for i, round in enumerate(self.rounds):
round["id"] = i + 1

def render(self, output_folder_path, output_filename="greedy_explanation.html"):
def render(self, output_folder_path, name=""):
"""
Render the visualisation.
Parameters
----------
output_folder_path : str
The path to the folder where the visualisation will be saved.
output_filename : str, optional
The name of the file. The default is "greedy_explanation.html".
name : str, optional
The prefix of the output files. The default is "".
Returns
-------
None
Expand All @@ -544,8 +544,9 @@ def render(self, output_folder_path, output_filename="greedy_explanation.html"):
spent=total_cost(p for p in self.instance if p.name in self.outcome),
budget=self.instance.meta["budget"],
total_votes=self.instance.meta["num_votes"],
name=name
)
if not os.path.exists(output_folder_path):
os.makedirs(output_folder_path)
with open(f"{output_folder_path}/{output_filename}", "w", encoding="utf-8") as o:
with open(f"{output_folder_path}/{name}_round_analysis.html", "w", encoding="utf-8") as o:
o.write(round_analysis_page_output)

0 comments on commit 4711e27

Please sign in to comment.