fix tip ordering for untyped Altair shorthand axes (0.2.1)#4
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Charts whose strain axis used positional shorthand without a type suffix —
alt.Y("strain")instead ofalt.Y("strain:N")— silently rendered in data order instead of tree-tip order. The field-extraction helper calledto_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 blanketexcept ExceptionreturnedNone, the live-object walker found no match, and the sort override was silently skipped.Replace the to_dict-based reader with one that inspects
_kwdsdirectly, handles plain-str fields, untyped/typed/aggregate shorthand, and theFieldName(SchemaBase)wrapper thatfrom_dictintroduces; 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
_buildapplies 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.