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

streams dont work when redim is applied on a source element later #2105

Closed
suvarchal opened this issue Nov 8, 2017 · 7 comments
Closed

streams dont work when redim is applied on a source element later #2105

suvarchal opened this issue Nov 8, 2017 · 7 comments
Labels
tag: API tag: backend: bokeh type: docs Related to the documentation and examples
Milestone

Comments

@suvarchal
Copy link

it was bizzare to me that streams didnt work when redim.range was applied on a stream source Element later on, ie.., after defining the stream. I wonder if it can be called a bug or a feature request.

it can be reproduced with a change to last line in holoviews Tap example

%opts HeatMap [width=700 height=500 logz=True fontsize={'xticks': '6pt'}, tools=['hover'] xrotation=90] (cmap='RdBu_r') 
%opts Curve [width=375 height=500 yaxis='right'] (line_color='black') {+framewise}

df = pd.read_csv('http://assets.holoviews.org/data/diseases.csv.gz', compression='gzip')
dataset = hv.Dataset(df, vdims=('measles','Measles Incidence'))

heatmap = hv.HeatMap(dataset.aggregate(['Year', 'State'], np.mean),
                 label='Measles Incidence').select(Year=(1928, 2002))

posxy = hv.streams.Tap(source=heatmap, x=1951, y='New York')

def tap_histogram(x, y):
       return hv.Curve(dataset.select(State=y, Year=int(x)), kdims='Week',
               label='Year: %s, State: %s' % (x, y))
heatmap.redim.range(measles=(0,1)) + hv.DynamicMap(tap_histogram, kdims=[], streams=[posxy])  

on tap the Curve plot does not change, it would be nice addition if after defining the stream if we could still apply redim.

@suvarchal suvarchal changed the title streams dont work on redim on an Element streams dont work when redim is applied on a source element later Nov 8, 2017
@philippjfr philippjfr added tag: backend: bokeh type: bug Something isn't correct or isn't working labels Nov 8, 2017
@philippjfr
Copy link
Member

This definitely should work so I've marked this as a bug.

@suvarchal
Copy link
Author

I wonder if it is because redim creates a clone of an Element which is not source anymore?

@philippjfr
Copy link
Member

I wonder if it is because redim creates a clone of an Element which is not source anymore?

Right, it's something like that but we do have mechanisms to handle that kind of thing. Basically applying methods to a DynamicMap builds a graph, which can be traversed to find the sources, seems like in this case something is going wrong there.

@philippjfr
Copy link
Member

Okay I just went through the example and looking at it again there is really no way this will ever work. HeatMap is a regular element so when you apply redim or indeed any other method you get a new object which is no longer linked to the stream. I would just make sure you apply redim before using the element as the source.

@jlstevens
Copy link
Contributor

Right - that does make sense. In this case, we should have a warning in the docs to explain this behaviour. Generally methods like redim and clone generate new elements which means they won't refer to whatever was passed as source.

@suvarchal
Copy link
Author

just to add not just heatmap any regular element like QuadMesh this would not work? may be a warning in documentation would avoid this pitfall.

@philippjfr philippjfr added tag: API type: docs Related to the documentation and examples and removed type: bug Something isn't correct or isn't working labels Nov 18, 2017
@philippjfr
Copy link
Member

So luckily I was completely wrong here, since 1.11.0 we now link objects with a shared _plot_id, which doesn't change unless the data is altered. Additionally, since #3478 we now inherit the plot_id on redim, which means the example above works just fine as is.

@philippjfr philippjfr added this to the v1.11.3 milestone Feb 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag: API tag: backend: bokeh type: docs Related to the documentation and examples
Projects
None yet
Development

No branches or pull requests

3 participants