Skip to content
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

Enhance resolve_dependent_value if value is list or tuples #5184

Merged
merged 6 commits into from
Feb 3, 2022

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Jan 19, 2022

Recursive calling resolve_dependent_value if value is a list or tuple. If this implementation crash and burn in the CI an alternative is the changes described here holoviz/hvplot#697 (comment).

This PR should make it able to run:

import holoviews as hv
import panel as pn
from bokeh.sampledata.autompg import autompg_clean as df

hv.extension("bokeh")

xaxis = pn.widgets.RadioButtonGroup(name="X axis", options=["mpg", "yr"])
ds = hv.Dataset(df)
transform = hv.util.transform.df_dim("*")
transform.groupby(["origin", xaxis]).apply(ds, keep_index=True, compute=False).mean()

Will add a unit test later this week.

@philippjfr
Copy link
Member

Nice, presumably we also need to ensure that it actually watches the widget/parameter though. Don't recall how offhand so if you don't see a way let me know and I'll dig into it.

@hoxbro
Copy link
Member Author

hoxbro commented Jan 19, 2022

I don't know if anything is needed in holoviews, but in hvplot the function hvplot.interactive._find_widgets should be updated with something similar to this.

holoviews/core/util.py Outdated Show resolved Hide resolved
@hoxbro
Copy link
Member Author

hoxbro commented Jan 22, 2022

This should now watch the widget/parameter. See:

example.mp4

The code:

import holoviews as hv
import hvplot.pandas  # noqa
import panel as pn
from bokeh.sampledata.autompg import autompg_clean as df

hv.extension("bokeh")

idf = df.interactive()

cylinders = pn.widgets.IntSlider(start=4, end=8, step=2, name="Cylinders")
mfr = pn.widgets.ToggleGroup(
    options=["ford", "chevrolet", "plymouth", "honda", "sbaru", "volkswagen"],
    value=["ford", "chevrolet", "plymouth", "honda", "sbaru", "volkswagen"],
)
xaxis = pn.widgets.RadioButtonGroup(name="X axis", options=["mpg", "yr"])
yaxis = pn.widgets.RadioButtonGroup(name="Y axis", options=["hp", "weight"])

ipipeline = (
    idf[(idf.mfr.isin(mfr)) & (idf.cyl == cylinders)]
    .groupby(["origin", xaxis])[yaxis]
    .mean()
)

pn.Column(ipipeline.hvplot(by="origin"), sizing_mode="stretch_both").servable()

I have noted the linecolor change when changing the yaxis, I don't know if this is a feature or a bug.

@hoxbro
Copy link
Member Author

hoxbro commented Jan 23, 2022

I have added an unittest. When trying to run the test suite on my computer it stops at holoviews/tests/plotting/bokeh/test_server.py and when I ctrl+c it returns TypeError: cannot create weak reference to 'NoneType' object. This seems to be related to changes made here holoviz/panel#2597.

@jbednar
Copy link
Member

jbednar commented Jan 23, 2022

This is really cool, @hoxbro ! Does anyone know of other Pandas or Xarray API argument types that remain unsupported? So far it seems like scalars, lists, tuples, and dictionaries are handled. I don't expect there are any arguments that take sets? Any other containers worth adding?

parameterized functions with dependencies on the supplied value.
Resolves parameter values, Parameterized instance methods,
parameterized functions with dependencies on the supplied value,
including such parameters embedded in a list or tuple.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be updated again with dictionary but will wait with an update until a final decision have been made.

@jbednar
Copy link
Member

jbednar commented Feb 3, 2022

@philippjfr , I'm eager to get this in place; is there anything else needed before merging, other than the docs fix above?

@philippjfr
Copy link
Member

Nice, all looks good. Will merge.

@philippjfr philippjfr merged commit 02d477b into holoviz:master Feb 3, 2022
@hoxbro hoxbro deleted the transform_groupby_list branch February 3, 2022 16:45
jlstevens added a commit that referenced this pull request Feb 7, 2022
hoxbro added a commit to hoxbro/holoviews that referenced this pull request Feb 8, 2022
Was not updated in holoviz#5184
@hoxbro hoxbro mentioned this pull request Feb 8, 2022
jbednar pushed a commit that referenced this pull request Feb 8, 2022
Was not updated in #5184
jlstevens added a commit that referenced this pull request Feb 14, 2022
Was not updated in #5184
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants