-
Notifications
You must be signed in to change notification settings - Fork 195
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
[py3dmol BUG] p.getView() does not return an array that could be used with p.setView(). #599
Comments
All communication between python and 3dmol is one-way by design (there is no need to have an active python kernel for 3dmol.js to work, which means notebooks can be shared as webpages). This is the intended behavior. |
Thanks for the quick feedback! Let me then state what I'm trying to do: However every time a slider is changed, the viewpoint get's reset. |
I can't run this, even when I give it access to Google Drive (which I'm not thrilled about), so I can only guess at the issues. py3Dmol works by writing javascript out to the page. colab sandboxes every output cell so it can't access javascript objects in other cells (outstanding issue #550). I suspect a new viewer is being created everytime you interact with the viewer object via interact. It is possible running p.update() will resolve the problem, but if the issue is that object is being sandboxed (meaning the previously created viewer isn't visible to the code that is currently running) then I'm not sure what can be done. |
(You should check the behavior in a local Jupyter notebook which doesn't sandbox cells). |
Thanks! I'm preparing a workshop on protein design, where my students will use Google colab, so optimally it should wok in colab. Would it help if I made a simpler example that does not require the huge PyRosetta package? PS: I forgot to say this before, but py3dmol is absolutely amazing! And without it an interactive protein design workshop would be much more boring and harder to organize (people would have to install pymol and then download the files to look at them etc). |
Yes, a minimal test case would be great. |
@dkoes Hi, here is minimal test case: https://colab.research.google.com/drive/1aSjw6yaRLUF7xYSwzAmv8twzqTro_sO_?usp=sharing |
You need to avoid instantiating another viewer, which is what is happening each time
|
Perfect, thank you! |
OMG thank you for this question, was trying the same thing (get/set view) to prevent the camera from resetting |
@benf549 Since I saw you are in rosetta commons, you might also be interested in a Rosetta specific viewer built on top of py3dmol: |
Describe the bug
p.getView() does not return an array that could be used with p.setView().
To Reproduce
https://colab.research.google.com/drive/1MNCej1_Ih6b1E_Ky4UHP7eRt8pr3_4-S?usp=sharing
Expected behavior
According to the docs an array should be returned, but a viewer instance is returned.
What is returned in py3dmol
The text was updated successfully, but these errors were encountered: