Skip to content

Commit

Permalink
Fixed emissions display when not measured (#1287)
Browse files Browse the repository at this point in the history
* Display 'N/A' in fitting report when emissions not measured

* fix failing windows tests
  • Loading branch information
jess-farmer committed May 24, 2024
1 parent cf9d1f1 commit 4e337ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 0 additions & 5 deletions examples/options_template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ make_plots: no

results_dir: new_results/

table_type: acc
runtime
compare
local_min

[LOGGING]

external_output: log_only
Expand Down
10 changes: 7 additions & 3 deletions fitbenchmarking/results_processing/fitting_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import os

import numpy as np

from jinja2 import Environment, FileSystemLoader

import fitbenchmarking
Expand Down Expand Up @@ -82,7 +81,12 @@ def create_prob_group(result, support_pages_dir, options):
css = get_css(options, support_pages_dir)
template = env.get_template("fitting_report_template.html")

with open(file_path, 'w') as fh:
if np.isnan(result.emissions):
emission_disp = 'N/A'
else:
emission_disp = f"{result.emissions:.4g} kg CO\u2082 eq"

with open(file_path, 'w', encoding='utf-8') as fh:
fh.write(template.render(
css_style_sheet=css['main'],
table_style=css['table'],
Expand All @@ -95,7 +99,7 @@ def create_prob_group(result, support_pages_dir, options):
minimizer=result.modified_minimizer_name(),
accuracy=f"{result.accuracy:.4g}",
runtime=f"{result.runtime:.4g}",
emissions=f"{result.emissions:.4g}",
emissions=emission_disp,
is_best_fit=result.is_best_fit,
initial_plot_available=init_success,
initial_plot=fig_start,
Expand Down
2 changes: 1 addition & 1 deletion fitbenchmarking/templates/fitting_report_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h2 class="handle">
<p><em>Minimizer</em>: {{ minimizer }}</p>
<p><em>Accuracy</em>: {{ accuracy }}</p>
<p><em>Runtime</em>: {{ runtime }} seconds</p>
<p><em>Emissions</em>: {{ emissions }} kg CO<sub>2</sub>eq</p>
<p><em>Emissions</em>: {{ emissions }}</p>
<p><em>Functions</em>:</p>
<table>
<colgroup>
Expand Down

0 comments on commit 4e337ab

Please sign in to comment.