-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Plotly.newPlot should be able to accept frozen objects #1339
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
Comments
I tried to "thaw" the object a tiny bit for Plotly with:
Now the plots are blank, yet there are no thrown errors. |
@rgbkrk thanks! For the second part, if you can post reproducible code (or a codepen) for it we can investigate this as a bug. For the first part - that's right, we actually mutate the input objects a fair amount - adding uids to traces seems to be the first instance but there are quite a few more. We've talked a fair amount (cc @etpinard ) about how this is not great practice but it will take a bunch of work if we decide to undo it. Another approach would be to deep-copy these objects as they're provided to Modifying a plot through the methods Anyway, this is definitely a discussion we should have, and all of this is up for grabs in v2.0. One thought I had - that I don't think is a good idea but I'll mention it just for completeness - is that we could check if any input object is frozen ( |
I definitely understand mutating these in place, especially for large traces. As long as I know that data I pass in gets mutated, that's ok. The way that I'm using data with plotly (as well as our other views) is in a manner that can be synchronized across multiple clients. One way of enforcing this during development is pure functions and immutability. As long as I know the best practice for me to setup a new plot (99% of the case), then we're golden. Checking if an object is frozen and either deep copying them or throwing an explicit error would be helpful. I think it's ok for the library to bail with a good error message (so developers see it early on in their development cycle). |
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson |
Much to my surprise, after updating nteract to load initial notebooks as frozen values via
Object.freeze
(recursively), I noticed thenewPlot
mutates thedata
parameter.The text was updated successfully, but these errors were encountered: