From b52faf38b37c51957104f70c47a204ad6db2a823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Wed, 7 Jun 2023 18:05:21 +0200 Subject: [PATCH] Fix float format error --- app/results/main_select.py | 18 ++++++++++++++---- app/results/templates/_table_dataset.html | 14 +++++++------- app/results/templates/_table_report.html | 10 +++++----- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app/results/main_select.py b/app/results/main_select.py index 05b9d6a..54a8474 100644 --- a/app/results/main_select.py +++ b/app/results/main_select.py @@ -107,13 +107,23 @@ def report(file_name): back = request.args.get("url") or "" back_name = request.args.get("url_name") or "" app_config = dotenv_values(".env") - with open(os.path.join(Folders.results, file_name)) as f: - data = json.load(f) try: - summary = process_data(file_name, current_app.config["COMPARE"], data) + with open(os.path.join(Folders.results, file_name)) as f: + data = json.load(f) + try: + summary = process_data( + file_name, current_app.config["COMPARE"], data + ) + except Exception as e: + return render_template( + "error.html", message=str(e), back=url_for("results.select") + ) except Exception as e: return render_template( - "error.html", message=str(e), back=url_for("results.select") + "error.html", + message=f"This results file ({file_name}) has not been found!", + error=str(e), + back=url_for("results.select"), ) return render_template( "report.html", diff --git a/app/results/templates/_table_dataset.html b/app/results/templates/_table_dataset.html index f291047..34439ee 100644 --- a/app/results/templates/_table_dataset.html +++ b/app/results/templates/_table_dataset.html @@ -56,13 +56,13 @@ {{ parts[3] }} {{ 'True' if stratified =='1' else 'False' }} {{ '{:,}'.format(item.samples) }} - {{"%d" % item.features }} - {{"%d" % item.classes }} - {{ '{:,.2f}'.format(item.nodes) }} - {{ '{:,}'.format(item.leaves) }} - {{ '{:,}'.format(item.depth) }} - {{"%.6f±%.4f" % (item.score, item.score_std)}} - {{"%.6f±%.4f" % (item.time, item.time_std)}} + {{ "%d" % item.features }} + {{ "%d" % item.classes }} + {{ '{:,.2f}'.format(item.nodes|float) }} + {{ '{:,.2f}'.format(item.leaves|float) }} + {{ '{:,.2f}'.format(item.depth|float) }} + {{ "%.6f±%.4f" % (item.score, item.score_std) }} + {{ "%.6f±%.4f" % (item.time, item.time_std) }} {{ item.hyperparameters }}