Skip to content

feat(pl): hex color passthrough, outline_width for nodes, annotation vmin/vmax fix#53

Merged
colganwi merged 2 commits intomainfrom
feat/hex-color-passthrough
Mar 29, 2026
Merged

feat(pl): hex color passthrough, outline_width for nodes, annotation vmin/vmax fix#53
colganwi merged 2 commits intomainfrom
feat/hex-color-passthrough

Conversation

@colganwi
Copy link
Copy Markdown
Collaborator

Summary

  • Hex color passthrough: When branch or node color data contains valid hex color strings, they are passed directly to matplotlib without palette mapping, enabling per-edge/per-node custom colors.
  • outline_width for nodes: New parameter draws a black outline around visible node markers; transparent (NA) nodes are excluded from the outline.
  • annotation vmin/vmax fix with label=False: Fixed IndexError when label=False is passed alongside vmin/vmax by guarding against empty label lists.

Test plan

  • test_hex_color_branches — branches render using raw hex RGBA values
  • test_hex_color_nodes — nodes render using raw hex RGBA values
  • test_nodes_outline_width — outline applied to visible nodes only; NA nodes stay transparent
  • test_annotation_vmin_vmax_label_false — no error when label=False with vmin/vmax

🤖 Generated with Claude Code

colganwi and others added 2 commits March 27, 2026 09:32
When a color attribute's values all start with '#' and are valid hex
color codes, _get_colors now passes them through directly to
matplotlib instead of routing through the categorical palette or
numeric colormap. This lets users pre-assign per-cell/per-branch
colors and have them rendered verbatim.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…h label=False

- pl.nodes: add outline_width parameter (default None) that draws a black
  border around visible nodes. Uses per-node edgecolors so transparent
  na nodes never receive a visible outline.
- pl.annotation: fix IndexError when label=False (labels=[]) is combined
  with vmin+vmax (which sets share_cmap=True) or an is_array key. The
  guards `if labels is not None` now use `if labels:` so an empty list
  correctly falls through to the auto-label logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@colganwi colganwi merged commit 4d64ddc into main Mar 29, 2026
7 checks passed
@colganwi colganwi deleted the feat/hex-color-passthrough branch March 29, 2026 19:10
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.92%. Comparing base (aa117e1) to head (35c776a).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/pycea/pl/plot_tree.py 84.61% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #53      +/-   ##
==========================================
+ Coverage   93.72%   93.92%   +0.20%     
==========================================
  Files          35       35              
  Lines        2916     2932      +16     
==========================================
+ Hits         2733     2754      +21     
+ Misses        183      178       -5     
Files with missing lines Coverage Δ
src/pycea/pl/_utils.py 89.91% <100.00%> (+0.21%) ⬆️
src/pycea/pl/plot_tree.py 95.14% <84.61%> (+1.85%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35c776a39b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

max_categories = 0
if is_array: # single cmap for all columns
label = labels[0] if labels is not None else keys[0]
label = labels[0] if labels else keys[0]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid boolean-casting arbitrary label sequences

This truthiness check will raise for valid Sequence[str] inputs like numpy.ndarray or pandas.Index (both commonly used to pass labels), because if labels triggers their ambiguous truth-value error. That makes annotation(..., label=<array-like>) crash in the is_array path even though this worked before the change (is not None), so the regression can break existing plotting calls that derive labels from array/index objects.

Useful? React with 👍 / 👎.

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