Skip to content

R23-T052: Add conversions/cmyk_to_rgb.py with round-trip doctests - #62

Open
code-paul-creator wants to merge 1 commit into
S-AI-Projects:masterfrom
code-paul-creator:R23-T052
Open

code-paul-creator wants to merge 1 commit into
S-AI-Projects:masterfrom
code-paul-creator:R23-T052

Conversation

@code-paul-creator

Copy link
Copy Markdown

Description

Adds conversions/cmyk_to_rgb.py, the inverse of rgb_cmyk_conversion.rgb_to_cmyk. It takes CMYK percentages (0..100), returns RGB in 0..255, has type hints, raises ValueError for invalid input, and has doctests including a round trip rgb -> cmyk -> rgb.

Related Issue

Fixes: #52

Type of Change

  • Bug Fix
  • New Feature
  • UI/UX Improvement
  • Performance Improvement
  • Tests
  • Documentation
  • Refactoring / Maintenance
  • CI/CD

Changes Made

  • Added conversions/cmyk_to_rgb.py (type hints, ValueError validation, doctests).
  • Doctests round-trip rgb -> cmyk (via rgb_to_cmyk) -> rgb within ±1 per channel for red, green, blue, white, black and gray.
  • Added work/R23-T052/VARIANT.md: time/space comparison, timing table and an explanation of the rounding.

Screenshots / Recordings

Not applicable (no UI changes).

Testing

  • python3 scripts/validate_filenames.py -> passed
  • ruff check conversions/cmyk_to_rgb.py -> all checks passed
  • python -m pytest --doctest-modules conversions/cmyk_to_rgb.py conversions/rgb_cmyk_conversion.py -> passed

Checklist

  • I have tested my changes locally.
  • I have added or updated tests, if needed.
  • I have updated documentation, if needed.
  • I have followed the project's coding guidelines.
  • I have run the relevant tests and checks.
  • I have addressed previous review feedback, if applicable.

Additional Notes

rgb_to_cmyk rounds to whole percentages, so the round trip is exact only for some colours. Over a sample of 140,608 colours the max error was 2 per channel (6,786 colours at 2, 106,608 at 1, 27,214 at 0). See work/R23-T052/VARIANT.md.

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.

Paulami Bhosle — R23-T052: Add a variant next to conversions/rgb_cmyk_conversion.py

1 participant