-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(RFC): Adds agg
, field
utility classes
#3505
Draft
dangotbanned
wants to merge
28
commits into
vega:main
Choose a base branch
from
dangotbanned:shorthand-namespace
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
`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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...Predicate
already has a constructor - the faux-parent
Predicate
class is just aUnion
- the unrelated
Field
class 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
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
field
proposed in More convenient syntax instead of FieldOneOfPredicate #3239 (comment)agg
was 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.py
until 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 | None
here:https://github.com/dangotbanned/altair/blob/0e806ce55db1acd7e8591c7eb0c30101baf26d2b/altair/vegalite/v5/_api_rfc.py#L147-L157