From 00154106280d3f9a16c2b5d070ad009cb089d069 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Wed, 18 Dec 2019 18:26:30 +0100 Subject: [PATCH] color the overhead between red and green (#252) color the overhead between red and green --- adaptive/notebook_integration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/adaptive/notebook_integration.py b/adaptive/notebook_integration.py index 017f951b2..3a06664d3 100644 --- a/adaptive/notebook_integration.py +++ b/adaptive/notebook_integration.py @@ -250,10 +250,14 @@ def _info_html(runner): "finished": "green", }[status] + overhead = runner.overhead() + red_level = max(0, min(int(255 * overhead / 100), 255)) + overhead_color = "#{:02x}{:02x}{:02x}".format(red_level, 255 - red_level, 0) + info = [ ("status", f'{status}'), ("elapsed time", datetime.timedelta(seconds=runner.elapsed_time())), - ("overhead", f"{runner.overhead():.2f}%"), + ("overhead", f'{overhead:.2f}%'), ] with suppress(Exception):