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

Styles going missing when slicing NdOverlays #221

Closed
jlstevens opened this issue Jul 18, 2015 · 6 comments
Closed

Styles going missing when slicing NdOverlays #221

jlstevens opened this issue Jul 18, 2015 · 6 comments

Comments

@jlstevens
Copy link
Contributor

In my work, I am generating an NdOverlay where the individual curves are customized by color:

traces = NdOverlay({float(c):Curve(d)(style={'color':col}) 
                    for c,(d, col) in data.items() }, kdims=['Contrast'])

The result has the colors I would expect but it seems the color settings are lost if I slice the NdOverlay. For instance, if I do traces[3.1:,:] to eliminate the 3% contrast trace, the NdOverlay seems to revert back to the default color cycle.

Edit: Fixed example.

@jlstevens jlstevens added the type: bug Something isn't correct or isn't working label Jul 18, 2015
@philippjfr
Copy link
Member

Wait I'm assuming that was a mistake but isn't the call in your example, i.e. traces() doing the clearing? Did you mean to do that or is there an actual bug if you get rid of the call?

@jlstevens
Copy link
Contributor Author

Yes sorry! Ignore the call (fixed above in an edit)

@philippjfr
Copy link
Member

Hmm, this is a more general problem to do with inheritance of the id attributes. By default the id is currently not inherited when performing a clone operation and since the __getitem__ just uses clone internally that is what happens. Should all clone operations inherit the id? If so this is an easy fix.

@philippjfr philippjfr added this to the v1.4.0 milestone Sep 11, 2015
@philippjfr philippjfr removed the type: bug Something isn't correct or isn't working label Sep 16, 2015
@philippjfr
Copy link
Member

As I said above this is not actually a bug, it's expected behavior. The question is do we want to change it? You could have avoided this issue altogether if you sliced only the NdOverlay not the Curves themselves, i.e. this traces[3.1:] instead of this traces[3.1:,:].

@jlstevens
Copy link
Contributor Author

I see what you mean now and I do think it is fairly confusing behavior. As a result, I think copying the ids across might be a good idea although I'll need time to think through all the possible consequences of this...

@philippjfr philippjfr mentioned this issue Nov 10, 2015
42 tasks
@philippjfr philippjfr removed this from the v1.4.0 milestone Nov 17, 2015
@philippjfr
Copy link
Member

This now works as you expected:

traces = hv.NdOverlay({col:hv.Curve(np.random.rand(10,2))(style={'color':col}) 
                       for i, col in enumerate(['red', 'green', 'blue']) }, kdims=['Contrast'])
traces[['red', 'green'], :]

Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants