From b0d20eb6539d15b8ffaf085de2d4c46ce50e29a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= Date: Fri, 27 Feb 2026 11:52:47 +0100 Subject: [PATCH] Remove errors in final copie --- annotating.py | 11 +++++++---- reading_annotations.py | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/annotating.py b/annotating.py index 2934ca8..fe9c1d8 100644 --- a/annotating.py +++ b/annotating.py @@ -215,7 +215,8 @@ def render_latex_text(text, width_px, bg_color=(255, 255, 255, 255), max_lines=N return final_img def render_score_text(label, score, error, width_px, fontsize=18, - bg_color=(255, 255, 255, 255)): + bg_color=(255, 255, 255, 255) + with_error=True): # 1. Calculate Color Gradient (0.0=DarkRed -> 4.0=Green) # Clamp score between 0 and 4 t = max(0.0, min(1.0, float(score) / 4.0)) @@ -229,7 +230,7 @@ def render_score_text(label, score, error, width_px, fontsize=18, # We use \color{hex} to color specific parts in Matplotlib score_str = f"{label} ; Note : \\color{{{hex_color}}}{{{score}}}" - if error and error != "null": + if error and error != "null" and with_error: # Uses standard Matplotlib color name 'orange' score_str += f" | \\color{{orange}}{{Error: {error}}}" @@ -268,7 +269,8 @@ def render_score_text(label, score, error, width_px, fontsize=18, def compose_label_image(base_img, label, result, hmin, render_fn=render_latex_text, - draw_callback=None): + draw_callback=None, + with_error=True): """ Composes the final image with annotations. @@ -295,7 +297,8 @@ def compose_label_image(base_img, label, result, hmin, # 1. Prepare Headers header_elements = [] - img_score = render_score_text(label, score, error, base_img.width // 2, fontsize=18) + img_score = render_score_text(label, score, error, base_img.width // 2, + fontsize=18, with_error) header_elements.append({"type": "score", "img": img_score, "data": result}) # Global Feedbacks diff --git a/reading_annotations.py b/reading_annotations.py index 1f81259..9e54ee1 100644 --- a/reading_annotations.py +++ b/reading_annotations.py @@ -249,7 +249,8 @@ def apply_actions_and_regenerate(root_dir, data, student_id, actions, notes_laye # Compose uses the result object we modified in step 1 final_img, _ = annotating.compose_label_image( - base_img, label, content['result'], content['coordinates'][0] + base_img, label, content['result'], content['coordinates'][0], + with_error=False ) # Overlay manual notes