-
Notifications
You must be signed in to change notification settings - Fork 795
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
Serialization of expr #2591
Serialization of expr #2591
Conversation
Defines a ParameterExpression class so that an expression like `theta_shift+5` no longer yields a Parameter. `theta_shift+5` can still be used in a chart, provided that `theta_shift` has been added to the chart.
Yes this works logically. I test a parameter expression as string and typed (through import altair as alt
from altair.expr import PI, length, data
data_wind = [
{'winddirection': 0, 'label': 'North'},
{'winddirection': 90, 'label': 'East'},
{'winddirection': 180, 'label': 'South'},
{'winddirection': 270, 'label': 'West'},
]
source_wind = alt.DataSource(alt.InlineData(values=data_wind, name='source_wind'))
par_expr_str = alt.parameter(expr="-PI/length(data('source_wind'))")
par_expr_type = alt.parameter(expr=-PI/length(data('source_wind')))
chart = alt.Chart(source_wind).mark_arc(
tooltip=True,
thetaOffset=par_expr_type + par_expr_str
).encode(
theta='winddirection:N',
color='label:N'
).add_parameter(par_expr_str, par_expr_type)
chart.to_dict()
Both are added as an unique parameter within the |
@ChristopherDavisUCI Could you remind me what was the reason for closing this PR? Was it superseded by one of the others you opened? I just want to make sure it wasn't closed accidentally. |
Hi @joelostblom, hmm, I honestly don't remember. Is there any easy way to tell what date it was closed? It might help to know what I was working on at the time. (Was it definitely closed by me?) I checked @mattijn's example from #2591 (comment) and in my current version it is not working the way @mattijn reported above. In Mattijn's version we have I will try to think some more. |
It looks like you might have deleted the repository that the PR was opened from. When I hover over the repo name above that is what it tells me: Because it was deleted that way, I don't think there is a way to know when it happened. But it does seem like the changes are still there in the files tab so maybe you can create a new branch on your current repo, copy in the changes and open a new PR? |
Thanks @joelostblom! I think I didn't realize I was closing this PR when I deleted that repository. I will try to re-create these changes. |
This is an attempt to resolve the issues @mattijn raised in #2573. Now an expression like
theta_shift+5
does not yield a Parameter but instead a new class ParameterExpression. If we have something defined likex = theta_shift+5
, we can't use something likeadd_parameter(x)
, becausex
is not a Parameter, but if we have usedadd_parameter(theta_shift)
, then we can usex
within the chart construction.Please let me know any comments!