Skip to content

Commit

Permalink
Introduce table classes for displaying multiline data
Browse files Browse the repository at this point in the history
Configure how long equations are displayed when they don't naturally fit in the width of the report
  • Loading branch information
youandvern committed Aug 9, 2024
1 parent 0b4c935 commit cf63cf0
Show file tree
Hide file tree
Showing 15 changed files with 462 additions and 23 deletions.
43 changes: 42 additions & 1 deletion docs/base_classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
<li><p><strong>reference</strong> (<em>str</em><em>, </em><em>optional</em>) – A short text reference (e.g. code reference) to accompany the comparison, defaults to None</p></li>
<li><p><strong>result_check</strong> (<em>bool</em><em>, </em><em>optional</em>) – This is used to indicate any <a class="reference internal" href="#efficalc.Comparison" title="efficalc.Comparison"><code class="xref py py-class docutils literal notranslate"><span class="pre">Comparison</span></code></a> that should be checked as a final result
of your calculation template. When set to True, this <a class="reference internal" href="#efficalc.Comparison" title="efficalc.Comparison"><code class="xref py py-class docutils literal notranslate"><span class="pre">Comparison</span></code></a> will be displayed in the “Results”
section of your design portal in the cloud version of efficalc, defaults to False</p></li>
section of your design portal in the cloud version of efficalc, defaults to True</p></li>
</ul>
</dd>
</dl>
Expand Down Expand Up @@ -651,6 +651,45 @@

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="efficalc.Table">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">efficalc.</span></span><span class="sig-name descname"><span class="pre">Table</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">headers</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">any</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">title</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">striped</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">full_width</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">result_check</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#efficalc.Table" title="Link to this definition">#</a></dt>
<dd><p>An object to display a table of data.</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>data</strong> (<em>List</em><em>[</em><em>List</em><em>[</em><em>Any</em><em>]</em><em>] </em><em>(</em><em>a 2d list where each inner list is a row in the table</em><em>)</em>) – The data in the table. If this is an input table, the data will act as default data to be overridden
by the calculation runner.</p></li>
<li><p><strong>headers</strong> (<em>List</em><em>[</em><em>Any</em><em>]</em><em>, </em><em>optional</em>) – The headers for the table, defaults to None</p></li>
<li><p><strong>title</strong> (<em>str</em><em>, </em><em>optional</em>) – The table title, defaults to None</p></li>
<li><p><strong>striped</strong> (<em>bool</em><em>, </em><em>optional</em>) – Whether the table should be striped, defaults to False</p></li>
<li><p><strong>full_width</strong> (<em>bool</em><em>, </em><em>optional</em>) – Whether the table should be full width, defaults to False</p></li>
<li><p><strong>result_check</strong> (<em>bool</em><em>, </em><em>optional</em>) – This is used to indicate any <a class="reference internal" href="#efficalc.Table" title="efficalc.Table"><code class="xref py py-class docutils literal notranslate"><span class="pre">Table</span></code></a> that should be checked as a final result
of your calculation template. When set to True, this <a class="reference internal" href="#efficalc.Table" title="efficalc.Table"><code class="xref py py-class docutils literal notranslate"><span class="pre">Table</span></code></a> will be displayed in the “Results”
section of your design portal in the cloud version of efficalc, defaults to False</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="efficalc.InputTable">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">efficalc.</span></span><span class="sig-name descname"><span class="pre">InputTable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">default_data</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">headers</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">any</span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">title</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">striped</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">full_width</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#efficalc.InputTable" title="Link to this definition">#</a></dt>
<dd><p>A table that can be used to accept dynamic input data with the calculation runner and cloud version of efficalc.</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>default_data</strong> (<em>List</em><em>[</em><em>List</em><em>[</em><em>Any</em><em>]</em><em>]</em>) – The default data for the table. This will be overridden when explicit calculation inputs are
provided to the calculation runner or in the design portal on the cloud version of efficalc</p></li>
<li><p><strong>headers</strong> (<em>List</em><em>[</em><em>Any</em><em>]</em>) – The headers for the table. This will be used as the unique identifier for the input table</p></li>
<li><p><strong>title</strong> (<em>str</em><em>, </em><em>optional</em>) – The table title, defaults to None</p></li>
<li><p><strong>striped</strong> (<em>bool</em><em>, </em><em>optional</em>) – Whether the table should be striped, defaults to False</p></li>
<li><p><strong>full_width</strong> (<em>bool</em><em>, </em><em>optional</em>) – Whether the table should be full width, defaults to True</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="efficalc.TextBlock">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">efficalc.</span></span><span class="sig-name descname"><span class="pre">TextBlock</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">text</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reference</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#efficalc.TextBlock" title="Link to this definition">#</a></dt>
Expand Down Expand Up @@ -774,6 +813,8 @@
<li><a class="reference internal" href="#efficalc.Symbolic.str_symbolic"><code class="docutils literal notranslate"><span class="pre">Symbolic.str_symbolic()</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#efficalc.Table"><code class="docutils literal notranslate"><span class="pre">Table</span></code></a></li>
<li><a class="reference internal" href="#efficalc.InputTable"><code class="docutils literal notranslate"><span class="pre">InputTable</span></code></a></li>
<li><a class="reference internal" href="#efficalc.TextBlock"><code class="docutils literal notranslate"><span class="pre">TextBlock</span></code></a></li>
<li><a class="reference internal" href="#efficalc.Title"><code class="docutils literal notranslate"><span class="pre">Title</span></code></a></li>
</ul>
Expand Down
20 changes: 19 additions & 1 deletion docs/calculation_helpers.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@

<dl class="py class">
<dt class="sig sig-object py" id="efficalc.report_builder.ReportBuilder">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">efficalc.report_builder.</span></span><span class="sig-name descname"><span class="pre">ReportBuilder</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">calc_function</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">input_vals</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">any</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#efficalc.report_builder.ReportBuilder" title="Link to this definition">#</a></dt>
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">efficalc.report_builder.</span></span><span class="sig-name descname"><span class="pre">ReportBuilder</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">calc_function</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">input_vals</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">any</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">long_calc_display</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#efficalc.report_builder.LongCalcDisplayType" title="efficalc.report_builder.LongCalcDisplayType"><span class="pre">LongCalcDisplayType</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">LongCalcDisplayType.SCALE</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#efficalc.report_builder.ReportBuilder" title="Link to this definition">#</a></dt>
<dd><p>A helper class to run calculation functions and generate reports based on the calculations.</p>
<p>This class provides methods to run a calculation function with optional input value overrides and generate an HTML
report to view or print the calculations. Reports can be viewed immediately in a web browser, saved to a file, or
Expand All @@ -289,6 +289,9 @@
<li><p><strong>input_vals</strong> (<em>dict</em><em>[</em><em>str</em><em>, </em><em>any</em><em>]</em><em>, </em><em>optional</em>) – A dictionary of values to override the calculation function’s default input values. Keys should
be the names of the input objects in the calculation function and values should be the desired values for the
input.</p></li>
<li><p><strong>long_calc_display</strong> (<a class="reference internal" href="#efficalc.report_builder.LongCalcDisplayType" title="efficalc.report_builder.LongCalcDisplayType"><em>LongCalcDisplayType</em></a><em>, </em><em>optional</em>) – How long expressions should be altered to fit within the calculation report width.
This can be either SCALE for scaling down the display size of the expression or LINEBREAK to break the
expression into multiple lines. defaults to SCALE</p></li>
</ul>
</dd>
</dl>
Expand Down Expand Up @@ -350,6 +353,20 @@

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="efficalc.report_builder.LongCalcDisplayType">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">efficalc.report_builder.</span></span><span class="sig-name descname"><span class="pre">LongCalcDisplayType</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">values</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">module</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qualname</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">start</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">boundary</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#efficalc.report_builder.LongCalcDisplayType" title="Link to this definition">#</a></dt>
<dd><p>An enumeration for controlling how to display long mathematical expressions in reports.</p>
<dl class="field-list simple">
<dt class="field-odd">Variables<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>SCALE</strong> – Scale the expression display and font size down to fit within the report width</p></li>
<li><p><strong>LINEBREAK</strong> – Break the expression into multiple lines to fit within the report width</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="efficalc.save_calculation_item">
<span class="sig-prename descclassname"><span class="pre">efficalc.</span></span><span class="sig-name descname"><span class="pre">save_calculation_item</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#efficalc.save_calculation_item" title="Link to this definition">#</a></dt>
Expand Down Expand Up @@ -456,6 +473,7 @@
<li><a class="reference internal" href="#efficalc.report_builder.ReportBuilder.view_report"><code class="docutils literal notranslate"><span class="pre">ReportBuilder.view_report()</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#efficalc.report_builder.LongCalcDisplayType"><code class="docutils literal notranslate"><span class="pre">LongCalcDisplayType</span></code></a></li>
<li><a class="reference internal" href="#efficalc.save_calculation_item"><code class="docutils literal notranslate"><span class="pre">save_calculation_item()</span></code></a></li>
<li><a class="reference internal" href="#efficalc.clear_saved_objects"><code class="docutils literal notranslate"><span class="pre">clear_saved_objects()</span></code></a></li>
<li><a class="reference internal" href="#efficalc.get_override_or_default_value"><code class="docutils literal notranslate"><span class="pre">get_override_or_default_value()</span></code></a></li>
Expand Down
Loading

0 comments on commit cf63cf0

Please sign in to comment.