Skip to content

Add cvd_simulate: simulate colour-vision deficiency and flag collisions#442

Merged
JE-Chen merged 1 commit into
devfrom
feat/cvd-simulate-batch
Jun 25, 2026
Merged

Add cvd_simulate: simulate colour-vision deficiency and flag collisions#442
JE-Chen merged 1 commit into
devfrom
feat/cvd-simulate-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

First feature of the ROUND-15 perception lane. Status UIs lean on colour (green "ok" vs red "error"), but for the ~8% of men with a colour-vision deficiency those can be indistinguishable — and nothing in the framework could check it.

  • Headless core utils/cvd_simulate/: simulate_cvd (map RGB through a dichromat simulation matrix — protanopia/deuteranopia/tritanopia — at a given severity, with friendly aliases), colors_collide (simulate two colours and report whether they become confusable: perceptual redmean distance below threshold), color_distance (the redmean metric). Pure standard library — no numpy/OpenCV — operating on plain RGB tuples, fully testable.
  • 5 layers wired: facade __all__; AC_simulate_cvd / AC_colors_collide executor commands (RGB inputs accept a JSON list); matching read-only ac_* MCP tools; Script Builder under Image.
  • Docs: EN + Zh v214_features_doc.rst + WHATS_NEW.md.

Test

test/unit_test/headless/test_cvd_simulate_batch.py — severity-0 identity, neutral-grey invariance (row sums = 1), red-shift under protanopia, aliases, unknown-kind raises, severity clamp, color_distance zero/symmetry, CVD reduces red-green distance, a genuinely colliding pair, black/white never collide, threshold respected, plus JSON-list executor coercion and facade + executor/MCP/builder wiring. All 15 green; ruff + bandit + radon clean; pytest.approx (no float ==); package stays Qt-free.

Status UIs lean on colour (green ok / red error), but for the ~8% of men
with a colour-vision deficiency those can be indistinguishable and nothing
could check it. simulate_cvd maps RGB through a dichromat matrix
(protan/deuter/tritan) at a severity; colors_collide reports whether two
colours become confusable under it. Pure stdlib over RGB tuples, no deps.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 28 complexity · 0 duplication

Metric Results
Complexity 28
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit ebe3fbc into dev Jun 25, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/cvd-simulate-batch branch June 25, 2026 23:43
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant