Unify semantic legend params.#727
Conversation
…e, cann't avoid list be forced to convert.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Try something. pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
There are at least two existing issues with this PR:
|
pass edgecolor ends up mulple args. Try unifying.
pre-commit.ci autofix
28198b2 to
c876eb0
Compare
|
call for pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Drop the debug `print()` in `_is_color_like` that fired twice for every RGBA tuple, accept 3- or 4-float lists symmetrically with tuples so `color=[0.5, 0.5, 0.5]` no longer crashes, and remove the redundant `if check_color and _is_color_like(val)` branch in `_style_lookup` whose two arms returned the same value. Split the eight numbered steps inside `_pop_entry_props` into three small helpers (`_pop_aliases`, `_pop_plurals`, `_pop_line2d_setters`) and reuse them from `_pop_num_props`. Replace the cryptic `# without this, line 645 of test_legend.py won't pass` comment with an explanation of which validator path actually depends on `label` / `labels` surviving, and the `LegendEntry.__init__` MarkerStyle branch gets a one-paragraph rationale. Misleading commented-out `ec` / `fc` lines come out of `_LINE_ALIAS_MAP` (they already work through ultraplot's existing `_pop_props`), and the short docstrings that the rewrite dropped on `UltraLegend.catlegend`, `sizelegend`, `numlegend`, `geolegend` and `entrylegend` are restored.
Fix the typo introduced when the new semantic-legend test module was added. Pure rename; no contents change.
PR Ultraplot#727 expands the semantic-legend surface (singular/plural aliases, list/dict per-entry resolution, RGBA-tuple disambiguation, advanced `MarkerStyle` properties on markers, patch-style passthrough on `geolegend` / `numlegend`) but the public-facing `Axes.*` wrappers still carry only one-line forwarder docstrings. Register four snippets in `legend.py` — `legend.semantic_style_arg`, `legend.semantic_style_kwargs`, `legend.semantic_num_style_kwargs`, `legend.semantic_handle_kw` — capturing the resolution rules and style vocabulary once. Wire the existing `docstring._snippet_manager` lazy loader to import `ultraplot.legend` on demand, then apply full numpy-style docstrings on `Axes.catlegend`, `entrylegend`, `sizelegend`, `numlegend` and `geolegend` using those snippets, so the same per-entry semantics and style alias table are documented in one place across five methods.
|
Thanks for the initiative @gepcel. Took a pass at tightening this up. First commit is the substantive cleanup of the legend rewrite — the stray print() in _is_color_like is gone, lists of three or four floats now work as a single color the same way tuples do (so color=[0.5, 0.5, 0.5] stops crashing), and a dead branch in _style_lookup that returned the same value either way is collapsed. The eight numbered steps inside _pop_entry_props are split into three small helpers that _pop_num_props reuses, the # without this, line 645 of test_legend.py won't pass comment is replaced with one that actually explains what it's guarding, and the misleading ec/fc lines come out of _LINE_ALIAS_MAP since they already work through _pop_props. The second commit is just renaming test_sematic_legend.py to fix the typo. The third commit adds real docs: a few shared snippets in legend.py feed numpy-style docstrings on the five public Axes.*legend methods, so the aliasvocabulary and per-entry rules live in one place instead of five. I hope this helps you on their way, and I think this addresses most of the issues you outlined. Let me know! |
|
I agree. |
for more information, see https://pre-commit.ci
|
Leave it up to you if we can merger @gepcel |
I think it's ready to merge. |
Addresses #726