feat(RFC): Adds agg, field utility classes#3505
Draft
dangotbanned wants to merge 32 commits intovega:mainfrom
Draft
feat(RFC): Adds agg, field utility classes#3505dangotbanned wants to merge 32 commits intovega:mainfrom
agg, field utility classes#3505dangotbanned wants to merge 32 commits intovega:mainfrom
Conversation
`field` proposed in vega#3239 (comment) `agg` was developed during vega#3427 (comment) as a solution to part of vega#3476
Mostly renaming, but also added `test_field_one_of_variadic`
Purely for visual demonstration
Ensures the same output from
```py
alt.Y("count()")
alt.Y(alt.agg.count())
```
dangotbanned
commented
Jul 26, 2024
| SelectionPredicateComposition({'field': 'Origin', 'oneOf': ['Japan', 'Europe']}) | ||
| """ | ||
|
|
||
| def __new__( # type: ignore[misc] |
Member
Author
There was a problem hiding this comment.
Wanted to highlight this current design quirk.
import altair as alt
>>> alt.field("Origin:N")
{'field': 'Origin', 'type': 'nominal'}
>>> alt.agg("Origin:N")
{'field': 'Origin', 'type': 'nominal'}- I'm anticipating users would expect
alt.field()to work this way, despite shorthand being unrelated. - I also think using
alt.agg()without specifying an aggregation wouldn't seem an intuitive way to define a field. - The other choices for what to return
- Each wrapped
Field...Predicatealready has a constructor - the faux-parent
Predicateclass is just aUnion - the unrelated
Fieldclass seems to be wrapping astr(not a{"field": "..."})
- Each wrapped
…/altair into shorthand-namespace
This was referenced Oct 31, 2024
- When I originally wrote this, not all of these were available - Overall, trying to reduce verbosity
Simply rewrites as `FieldValidPredicate("field", valid=False)`
> If set to true the field's value has to be valid, meaning both not ``null`` and not NaN
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.
Will close #3239
Description
fieldproposed in More convenient syntax instead ofFieldOneOfPredicate#3239 (comment)aggwas developed during 3427#issuecomment-2228454241 as a solution to part of Post-SciPy 2024 tutorial notes #3476I've isolated these into a new module.
Currently, this is only to support discussions like #3239 (comment) to test out the syntax/design.
Status
I'm not looking to add these into
api.pyuntil these are resolved:They will be too difficult to find currently, but having this in a public branch will make refining the design easier.
Related Issues
#1642 can be solved by accepting
str | Mapping | Nonehere:https://github.com/dangotbanned/altair/blob/0e806ce55db1acd7e8591c7eb0c30101baf26d2b/altair/vegalite/v5/_api_rfc.py#L147-L157