Skip to content

Commit

Permalink
Updated typing
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Rey committed Oct 25, 2023
1 parent f89cd51 commit 2e4ef7b
Show file tree
Hide file tree
Showing 79 changed files with 5,174 additions and 1,140 deletions.
2 changes: 1 addition & 1 deletion analysis/analysis_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def runtime_analysis_plot(csv_file="runtime.csv", xaxis="num_projects_cat"):
g.set_title("MES[Cost_Sat] resolute and exhaustive (budget increase)")
else:
g.set_title(rule)
g.set_xlabel("Number of projects")
g.set_xlabel("Numeric of projects")
g.set_ylabel("Runtime")

plt.show()
Expand Down
1 change: 1 addition & 0 deletions docs/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ <h1>All modules for which code is available</h1>
<li><a href="pabutools/rules/phragmen.html">pabutools.rules.phragmen</a></li>
<li><a href="pabutools/tiebreaking.html">pabutools.tiebreaking</a></li>
<li><a href="pabutools/utils.html">pabutools.utils</a></li>
<li><a href="typing.html">typing</a></li>
</ul>

</article>
Expand Down
11 changes: 6 additions & 5 deletions docs/_modules/pabutools/analysis/category.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,9 @@ <h1></h1>
<article class="bd-article" role="main">

<h1>Source code for pabutools.analysis.category</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">collections.abc</span> <span class="kn">import</span> <span class="n">Iterable</span>
<span class="kn">from</span> <span class="nn">numbers</span> <span class="kn">import</span> <span class="n">Number</span>
<span></span><span class="kn">from</span> <span class="nn">collections.abc</span> <span class="kn">import</span> <span class="n">Collection</span>

<span class="kn">from</span> <span class="nn">pabutools.utils</span> <span class="kn">import</span> <span class="n">Numeric</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

Expand All @@ -265,8 +266,8 @@ <h1>Source code for pabutools.analysis.category</h1><div class="highlight"><pre>
<div class="viewcode-block" id="category_proportionality"><a class="viewcode-back" href="../../../reference/analysis/index.html#pabutools.analysis.category.category_proportionality">[docs]</a><span class="k">def</span> <span class="nf">category_proportionality</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">AbstractApprovalProfile</span><span class="p">,</span>
<span class="n">budget_allocation</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="p">)</span> <span class="o">-&gt;</span> <span class="n">Number</span><span class="p">:</span>
<span class="n">budget_allocation</span><span class="p">:</span> <span class="n">Collection</span><span class="p">[</span><span class="n">Project</span><span class="p">],</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Numeric</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Computes the difference between the cost allocated per category, and that existing in the profile. More</span>
<span class="sd"> specifically, for each category (an error is raised if not category are specified) we compute the amount of money</span>
Expand All @@ -288,7 +289,7 @@ <h1>Source code for pabutools.analysis.category</h1><div class="highlight"><pre>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> Number</span>
<span class="sd"> Numeric</span>
<span class="sd"> The score for the category proportionality.</span>

<span class="sd"> &quot;&quot;&quot;</span>
Expand Down
22 changes: 11 additions & 11 deletions docs/_modules/pabutools/analysis/instanceproperties.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,14 @@ <h1></h1>
<h1>Source code for pabutools.analysis.instanceproperties</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">pabutools.election.instance</span> <span class="kn">import</span> <span class="n">Instance</span><span class="p">,</span> <span class="n">total_cost</span>

<span class="kn">from</span> <span class="nn">numbers</span> <span class="kn">import</span> <span class="n">Number</span>
<span class="kn">from</span> <span class="nn">pabutools.utils</span> <span class="kn">import</span> <span class="n">Numeric</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

<span class="kn">from</span> <span class="nn">pabutools.fractions</span> <span class="kn">import</span> <span class="n">frac</span>


<div class="viewcode-block" id="sum_project_cost"><a class="viewcode-back" href="../../../reference/analysis/index.html#pabutools.analysis.instanceproperties.sum_project_cost">[docs]</a><span class="k">def</span> <span class="nf">sum_project_cost</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="o">-&gt;</span> <span class="n">Number</span><span class="p">:</span>
<div class="viewcode-block" id="sum_project_cost"><a class="viewcode-back" href="../../../reference/analysis/index.html#pabutools.analysis.instanceproperties.sum_project_cost">[docs]</a><span class="k">def</span> <span class="nf">sum_project_cost</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="o">-&gt;</span> <span class="n">Numeric</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns the total cost of all the projects in the instance.</span>

Expand All @@ -274,14 +274,14 @@ <h1>Source code for pabutools.analysis.instanceproperties</h1><div class="highli

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> Number</span>
<span class="sd"> Numeric</span>
<span class="sd"> The total cost.</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">total_cost</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span></div>


<div class="viewcode-block" id="funding_scarcity"><a class="viewcode-back" href="../../../reference/analysis/index.html#pabutools.analysis.instanceproperties.funding_scarcity">[docs]</a><span class="k">def</span> <span class="nf">funding_scarcity</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="o">-&gt;</span> <span class="n">Number</span><span class="p">:</span>
<div class="viewcode-block" id="funding_scarcity"><a class="viewcode-back" href="../../../reference/analysis/index.html#pabutools.analysis.instanceproperties.funding_scarcity">[docs]</a><span class="k">def</span> <span class="nf">funding_scarcity</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="o">-&gt;</span> <span class="n">Numeric</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns the ratio of the total cost of the instance, divided by the budget limit. This measure is called the funding</span>
<span class="sd"> scarcity.</span>
Expand All @@ -293,7 +293,7 @@ <h1>Source code for pabutools.analysis.instanceproperties</h1><div class="highli

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> Number</span>
<span class="sd"> Numeric</span>
<span class="sd"> The funding scarcity of the instance.</span>

<span class="sd"> &quot;&quot;&quot;</span>
Expand All @@ -304,7 +304,7 @@ <h1>Source code for pabutools.analysis.instanceproperties</h1><div class="highli
<span class="p">)</span></div>


<div class="viewcode-block" id="avg_project_cost"><a class="viewcode-back" href="../../../reference/analysis/index.html#pabutools.analysis.instanceproperties.avg_project_cost">[docs]</a><span class="k">def</span> <span class="nf">avg_project_cost</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="o">-&gt;</span> <span class="n">Number</span><span class="p">:</span>
<div class="viewcode-block" id="avg_project_cost"><a class="viewcode-back" href="../../../reference/analysis/index.html#pabutools.analysis.instanceproperties.avg_project_cost">[docs]</a><span class="k">def</span> <span class="nf">avg_project_cost</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="o">-&gt;</span> <span class="n">Numeric</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns the average cost of a project.</span>

Expand All @@ -315,14 +315,14 @@ <h1>Source code for pabutools.analysis.instanceproperties</h1><div class="highli

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> Number</span>
<span class="sd"> Numeric</span>
<span class="sd"> The average cost of a project.</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">frac</span><span class="p">(</span><span class="n">total_cost</span><span class="p">(</span><span class="n">instance</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="n">instance</span><span class="p">))</span></div>


<div class="viewcode-block" id="median_project_cost"><a class="viewcode-back" href="../../../reference/analysis/index.html#pabutools.analysis.instanceproperties.median_project_cost">[docs]</a><span class="k">def</span> <span class="nf">median_project_cost</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="o">-&gt;</span> <span class="n">Number</span><span class="p">:</span>
<div class="viewcode-block" id="median_project_cost"><a class="viewcode-back" href="../../../reference/analysis/index.html#pabutools.analysis.instanceproperties.median_project_cost">[docs]</a><span class="k">def</span> <span class="nf">median_project_cost</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="o">-&gt;</span> <span class="n">Numeric</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns the median cost of a project.</span>

Expand All @@ -333,14 +333,14 @@ <h1>Source code for pabutools.analysis.instanceproperties</h1><div class="highli

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> Number</span>
<span class="sd"> Numeric</span>
<span class="sd"> The median cost of a project.</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="nb">float</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">median</span><span class="p">([</span><span class="n">project</span><span class="o">.</span><span class="n">cost</span> <span class="k">for</span> <span class="n">project</span> <span class="ow">in</span> <span class="n">instance</span><span class="p">]))</span></div>


<div class="viewcode-block" id="std_dev_project_cost"><a class="viewcode-back" href="../../../reference/analysis/index.html#pabutools.analysis.instanceproperties.std_dev_project_cost">[docs]</a><span class="k">def</span> <span class="nf">std_dev_project_cost</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="o">-&gt;</span> <span class="n">Number</span><span class="p">:</span>
<div class="viewcode-block" id="std_dev_project_cost"><a class="viewcode-back" href="../../../reference/analysis/index.html#pabutools.analysis.instanceproperties.std_dev_project_cost">[docs]</a><span class="k">def</span> <span class="nf">std_dev_project_cost</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="o">-&gt;</span> <span class="n">Numeric</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns the standard deviation of the costs of the projects.</span>

Expand All @@ -351,7 +351,7 @@ <h1>Source code for pabutools.analysis.instanceproperties</h1><div class="highli

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> Number</span>
<span class="sd"> Numeric</span>
<span class="sd"> The standard deviation.</span>

<span class="sd"> &quot;&quot;&quot;</span>
Expand Down
Loading

0 comments on commit 2e4ef7b

Please sign in to comment.