Skip to content

fix tip ordering for untyped Altair shorthand axes (0.2.1)#4

Merged
jbloom merged 1 commit intomainfrom
fix-tip-ordering-bug
May 6, 2026
Merged

fix tip ordering for untyped Altair shorthand axes (0.2.1)#4
jbloom merged 1 commit intomainfrom
fix-tip-ordering-bug

Conversation

@jbloom
Copy link
Copy Markdown
Member

@jbloom jbloom commented May 6, 2026

Charts whose strain axis used positional shorthand without a type suffix — alt.Y("strain") instead of alt.Y("strain:N") — silently rendered in data order instead of tree-tip order. The field-extraction helper called to_dict() on the bare channel, which raises when the shorthand has no explicit type because Altair needs a chart-data context to infer it. The blanket except Exception returned None, the live-object walker found no match, and the sort override was silently skipped.

Replace the to_dict-based reader with one that inspects _kwds directly, handles plain-str fields, untyped/typed/aggregate shorthand, and the FieldName(SchemaBase) wrapper that from_dict introduces; raise on unrecognized shapes instead of swallowing them.

Add a structural fail-fast tripwire: count strain-axis encodings on the spec walk and on the live-object walk, and raise on any mismatch. Catches both this bug and any future divergence between the two surfaces.

Consolidate the two near-identical live-object walkers (sort application and axis suppression) into a single read-only generator yielding live channel objects; the call site in _build applies sort and (conditionally) axis suppression at each yielded channel and counts hits for the tripwire. Removes ~70 lines of duplicated traversal logic.

Tests: 11 new unit and end-to-end tests covering typed/untyped/ explicit/aggregate shorthand, the from_dict-roundtripped wrapper, value-only encodings (legitimate None), unparseable shorthand (raises), non-channel objects (raises), tip ordering for untyped shorthand on x and y, and the tripwire firing when the live walker misses a strain encoding the spec walker found.

Charts whose strain axis used positional shorthand without a type
suffix — `alt.Y("strain")` instead of `alt.Y("strain:N")` — silently
rendered in data order instead of tree-tip order. The field-extraction
helper called `to_dict()` on the bare channel, which raises when the
shorthand has no explicit type because Altair needs a chart-data
context to infer it. The blanket `except Exception` returned `None`,
the live-object walker found no match, and the sort override was
silently skipped.

Replace the to_dict-based reader with one that inspects `_kwds`
directly, handles plain-str fields, untyped/typed/aggregate shorthand,
and the `FieldName(SchemaBase)` wrapper that `from_dict` introduces;
raise on unrecognized shapes instead of swallowing them.

Add a structural fail-fast tripwire: count strain-axis encodings on
the spec walk and on the live-object walk, and raise on any mismatch.
Catches both this bug and any future divergence between the two
surfaces.

Consolidate the two near-identical live-object walkers (sort
application and axis suppression) into a single read-only generator
yielding live channel objects; the call site in `_build` applies sort
and (conditionally) axis suppression at each yielded channel and
counts hits for the tripwire. Removes ~70 lines of duplicated
traversal logic.

Tests: 11 new unit and end-to-end tests covering typed/untyped/
explicit/aggregate shorthand, the from_dict-roundtripped wrapper,
value-only encodings (legitimate None), unparseable shorthand
(raises), non-channel objects (raises), tip ordering for untyped
shorthand on x and y, and the tripwire firing when the live walker
misses a strain encoding the spec walker found.
@jbloom jbloom merged commit 64fcc26 into main May 6, 2026
3 checks passed
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