Repository navigation
R23-T052: Add conversions/cmyk_to_rgb.py with round-trip doctests - #62
Open
code-paul-creator wants to merge 1 commit into
Open
code-paul-creator wants to merge 1 commit into
code-paul-creator wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
conversions/cmyk_to_rgb.py, the inverse ofrgb_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
Changes Made
conversions/cmyk_to_rgb.py(type hints, ValueError validation, doctests).rgb_to_cmyk) -> rgb within ±1 per channel for red, green, blue, white, black and gray.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-> passedruff check conversions/cmyk_to_rgb.py-> all checks passedpython -m pytest --doctest-modules conversions/cmyk_to_rgb.py conversions/rgb_cmyk_conversion.py-> passedChecklist
Additional Notes
rgb_to_cmykrounds 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). Seework/R23-T052/VARIANT.md.