Skip to content

chore: dithering binding robustness, pipeline repair, and docs#48

Open
davelee98 wants to merge 2 commits into
OpenDisplay:mainfrom
davelee98:chore/dithering-robustness-tooling-docs
Open

chore: dithering binding robustness, pipeline repair, and docs#48
davelee98 wants to merge 2 commits into
OpenDisplay:mainfrom
davelee98:chore/dithering-robustness-tooling-docs

Conversation

@davelee98

Copy link
Copy Markdown
Contributor

Phases 3-5 of the dithering code-review follow-up: binding robustness, tooling, and docs. Follows #45 (now merged); rebased onto main, so this contains only its own changes.

Robustness

  • ImageBuffer::new validates width and buffer length (panics on zero width / ragged buffer) instead of silently truncating in release builds; backed by unit tests.
  • Python and WASM dither_image validate image dimensions and accent_idx before constructing the buffer/palette, returning proper ValueError/JsValue errors instead of panicking the extension.
  • JS ditherImage throws a clear error when a measured palette's accent name isn't one of its colors (previously passed -1 into WASM → opaque abort). New vitest case.

Tooling & docs

  • Expose tone_compress, gamut_compress, and rgb_to_oklab_buffer on the Python _rs module and repair scripts/pipeline.py, which imported modules deleted in the Rust port. Verified it runs end-to-end producing the 6-panel visualization.
  • Drop the stale examples/wab_sweep.rs reference in the WAB doc comment (the file never existed).
  • CALIBRATION.md: document that palette values must be sRGB-encoded (not linear-light), with the encoding formula for linear-workflow (DNG) measurements — otherwise every color reads too dark.

CHANGELOGs updated for all three packages (covering the #45 fixes and these changes).

Verification

Core 51 unit + 3 regression tests, Python 81 pytest, JS 39 vitest all pass; WASM core rebuilt; pipeline.py runs clean and ruff-checked.

🤖 Generated with Claude Code

Phases 3-5 of the code-review follow-up (stacked on the math + perf fixes):

Robustness (Issues OpenDisplay#7, OpenDisplay#9):
- ImageBuffer::new validates width and buffer length (panics on zero width / ragged
  buffer) instead of silently truncating in release; contract backstopped by tests.
- Python and WASM dither_image validate image dimensions and accent_idx before
  constructing the buffer/palette, returning proper ValueError/JsValue errors rather
  than panicking the extension.
- JS ditherImage throws a clear error when a measured palette's accent name is not one
  of its colors (previously passed -1 into WASM → opaque abort). Adds a vitest case.

Tooling & docs (Issues OpenDisplay#5, OpenDisplay#6, OpenDisplay#10):
- Expose tone_compress, gamut_compress, and rgb_to_oklab_buffer on the Python _rs module
  and repair scripts/pipeline.py, which imported modules deleted in the Rust port. Runs
  end-to-end again.
- Drop the stale examples/wab_sweep.rs reference in the WAB doc comment.
- CALIBRATION.md: document that palette values must be sRGB-encoded (not linear-light),
  with the encoding formula for linear-workflow (DNG) measurements.

CHANGELOGs updated for all three packages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Match the project ruff config (import ordering + single-line stub signatures)
so the prek/ruff-format CI hook passes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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