Skip to content

Clarify write_png normalization and color-preserving input - #242

Open
dmwong25 wants to merge 1 commit into
python-visualization:mainfrom
dmwong25:docs/write-png-normalization
Open

dmwong25 wants to merge 1 commit into
python-visualization:mainfrom
dmwong25:docs/write-png-normalization

Conversation

@dmwong25

Copy link
Copy Markdown

Summary

Document the existing channel normalization in write_png, including the normalization of the alpha channel and of uint8 RGB input after an alpha channel is added. Show how callers can preserve RGB colors by preparing a uint8 RGBA array.

Also replace the Python 2 base64 example with an executable Python 3 example and add focused pixel-level tests for the documented behavior. The test helper uses only the standard library to decode the generated PNG scanlines.

This is a documentation and test contribution related to #195. It does not change normalization behavior, add an option, or resolve the request to change that behavior.

Verification

  • python -m pytest -vv -rxs tests -m 'not headless': 39 passed, 2 deselected.
  • All 9 examples in the write_png docstring execute successfully.
  • Focused Sphinx build of the changed docstring passes with warnings treated as errors.
  • Full documentation HTML build succeeds with the existing missing _static directory warning.
  • Black, isort, Flake8, mypy, and git diff --check pass.
  • Browser/headless tests, notebook tests, and the full multi-platform CI matrix were not run locally.

Prepared with AI assistance. The documentation, decoded pixel results, examples, and local checks were reviewed; no claim of maintainer endorsement is intended.

This branch has not been deployed

No deployments
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