Skip to content

Conversation

@dcherian
Copy link
Collaborator

Summary

This PR adds support for RGBA hex colors (#RRGGBBAA) in custom colormaps while maintaining full backward compatibility with existing RGB (#RRGGBB) colormaps.

Changes

  • Validator: Updated validate_colormap() to accept both #RRGGBB and #RRGGBBAA formats
  • Tests: Added comprehensive unit tests for RGBA validation (mixed RGB/RGBA, transparency levels, invalid formats)
  • Integration Test: Added test with categorical data using RGBA colormap with fully transparent category
  • Testing Library: Added helper functions assert_has_transparent_pixels() and assert_has_opaque_pixels()
  • Documentation: Updated README with RGBA support examples and tips
  • Type Hints: Updated field descriptions in TileQuery and WMSGetMapQuery to document RGBA support
  • Comments: Added note about matplotlib's native RGBA support in LinearSegmentedColormap

Backward Compatibility

✅ Fully backward compatible - all existing RGB-only colormaps continue to work without changes

Test Results

  • All existing colormap tests pass
  • 6 new RGBA-specific tests added and passing
  • New snapshot test verifies alpha channel rendering works correctly
  • Pre-commit checks pass

Example Usage

# Continuous data with transparency gradient
colormap = {
    "0": "#0000ffff",    # Blue, fully opaque
    "128": "#00ff0080",  # Green, 50% transparent  
    "255": "#ff000000"   # Red, fully transparent
}

# Categorical data with one transparent category
colormap = {
    "0": "#ff000000",  # Transparent
    "1": "#00ff00ff",  # Green, opaque
    "2": "#0000ffff"   # Blue, opaque
}

🤖 Generated with Claude Code

dcherian and others added 2 commits December 29, 2025 09:54
- Update colormap validator to accept #RRGGBBAA format in addition to #RRGGBB
- Add comprehensive unit tests for RGBA validation (mixed RGB/RGBA, transparency levels, invalid formats)
- Add integration test with categorical data using RGBA colormap with transparent category
- Add helper functions assert_has_transparent_pixels() and assert_has_opaque_pixels() in testing lib
- Update README documentation to describe RGBA support with examples
- Update API type hints and docstrings in TileQuery and WMSGetMapQuery
- Add matplotlib compatibility comment noting LinearSegmentedColormap supports RGBA
- All changes are backward compatible - existing RGB colormaps continue to work

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Switch from para_north_z4 (edge tile) to para_belem_z6 (Belém capital area)
- This ensures transparent pixels are only from RGBA colormap, not missing data
- Test now properly validates alpha channel rendering with category 0 transparent

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@codecov
Copy link

codecov bot commented Dec 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.45%. Comparing base (9afa5fe) to head (5aa984c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #176   +/-   ##
=======================================
  Coverage   75.45%   75.45%           
=======================================
  Files          26       26           
  Lines        3541     3541           
=======================================
  Hits         2672     2672           
  Misses        869      869           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dcherian dcherian marked this pull request as draft December 29, 2025 18:43
@dcherian
Copy link
Collaborator Author

This is blocked by holoviz/datashader#1404

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.

2 participants