Merge pull request 'Leave reference sample ΔE blank in CSV and HTML' (#2) from cursor/empty-reference-delta-e into main
Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
@@ -117,10 +117,11 @@ def de2000(lab1, lab2) -> float:
|
||||
def add_delta_e(rows: list[dict], references: dict[str, str]) -> bool:
|
||||
"""Add a CIEDE2000 column to each averaged row vs that sample's reference.
|
||||
|
||||
Samples absent from `references` are references themselves (dE00 = 0).
|
||||
Returns True if the column was written (only when at least one sample
|
||||
names a reference). Never raises so the scan pipeline can continue even
|
||||
when a named reference is missing.
|
||||
Samples absent from `references` are references themselves (dE00 left
|
||||
empty — they have no external comparison). Returns True if the column
|
||||
was written (only when at least one sample names a reference). Never
|
||||
raises so the scan pipeline can continue even when a named reference
|
||||
is missing.
|
||||
"""
|
||||
if not rows or not references:
|
||||
return False
|
||||
@@ -131,7 +132,7 @@ def add_delta_e(rows: list[dict], references: dict[str, str]) -> bool:
|
||||
sid = row["sample_id"]
|
||||
ref_id = references.get(sid)
|
||||
if ref_id is None:
|
||||
row[DE_COL] = 0.0
|
||||
row[DE_COL] = ""
|
||||
wrote = True
|
||||
continue
|
||||
ref_row = by_id.get(ref_id)
|
||||
@@ -221,10 +222,10 @@ def write_html(
|
||||
if has_de:
|
||||
raw = r.get(DE_COL, "")
|
||||
if raw == "" or raw is None:
|
||||
cells.append('<td class="de">—</td>')
|
||||
cells.append("<td>—</td>")
|
||||
else:
|
||||
d = float(raw)
|
||||
de_cls = "de win" if is_ref else ("de bad" if d >= 3.5 else "de")
|
||||
de_cls = "de bad" if d >= 3.5 else "de"
|
||||
cells.append(
|
||||
f'<td class="{de_cls}" title="{esc(de_bucket(d))}">{d:.2f}</td>'
|
||||
)
|
||||
@@ -252,7 +253,7 @@ def write_html(
|
||||
<title>Averaged color measurements</title>
|
||||
<style>
|
||||
:root {{ --text:#1f2328; --text2:#57606a; --text3:#8b949e; --stroke:#d0d7de;
|
||||
--bg:#fff; --fill:#f6f8fa; --good:#1a7f37; --bad:#bc4c00; }}
|
||||
--bg:#fff; --fill:#f6f8fa; --bad:#bc4c00; }}
|
||||
* {{ box-sizing:border-box; }}
|
||||
body {{ margin:0; padding:32px 24px 48px; background:var(--bg); color:var(--text);
|
||||
font:14px/1.5 -apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif; }}
|
||||
@@ -278,7 +279,6 @@ def write_html(
|
||||
.tag {{ font-size:11px; color:var(--text3); border:1px solid var(--stroke);
|
||||
border-radius:4px; padding:0 5px; margin-left:6px; }}
|
||||
.de {{ font-weight:600; }}
|
||||
.win {{ color:var(--good); }}
|
||||
.bad {{ color:var(--bad); }}
|
||||
.faint {{ color:var(--text3); font-size:12px; margin-top:14px; }}
|
||||
@media print {{ body {{ padding:0; }} }}
|
||||
|
||||
Reference in New Issue
Block a user