Comments (16)
Go into pyzx/utils.py and comment out the block of lines 95-104 (the try-except block).
What browser are you using?
Seeing as this is a problem for more people I think I'm just gonna bite the bullet and include a copy of d3 with pyzx.
from pyzx.
Hmm, or I could insert a check to see if the file can be found on the filesystem, and if not it defaults to the online copy.
Or was the problem that even forcing it to use the online copy doesn't work?
from pyzx.
So the original problem was with using the online copy. Adding the d3 file locally was my solution to this.
from pyzx.
I still don't understand this bug. Forcing PyZX to use the online copy at https://d3js.org/d3.v5.min.js works fine for me. Which browser are you using, and which version of Jupyter?
from pyzx.
Hello,
I am having a look at pyZX and when following the "getting started" examples zx.draw does nothing. It seems to be a d3js issue.
How do I "force PyZX to use the online copy at https://d3js.org/d3.v5.min.js" ?
Thanks !
from pyzx.
from pyzx.
from pyzx.
Ah yes. It doesn't work me either if I try it with jupyterlab. So it turns out that for jupyterlab you have to manually enable extensions (https://ipywidgets.readthedocs.io/en/latest/user_install.html#installing-the-jupyterlab-extension), which also requires installing node.js. But even after following the instructions I still get the javascript error that 'require' is not defined. I think this has to do with jupyterlab being a bit more strict about how you can execute javascript in a cell. To solve this would require making a separate PyZX extension to jupyterlab, which I am not going to do any time soon.
So my suggestion is to use the classic notebook interface (i.e. in jupyterlab go to Help -> Launch classic notebook)
from pyzx.
@RDPEast were you also using jupyterlab?
from pyzx.
No I'm using the notebook, though I still rely on the hard copy of the file. I believe others (i.e Nick) have also encountered problems with just the notebook and downloading the d3 file.
from pyzx.
What does it say in the javascript console when you try it with using the online copy?
from pyzx.
Hi John,
So this is a copy and paste from back when it didn't function (I'm loath to undo the changes I've made to my version of pyzx to double check as it was quite tempermental at first for reasons I still don't understand and I'm rather dependent on the editor at this precise moment)
from pyzx.
Hmm, I find it interesting that you get a script error before it says "Loading extension: jupyter-js-widgets/extension". That seems to me like an error in your jupyter server, but I really don't understand enough of this to be sure.
from pyzx.
So another thing I encountered that might explain this: If you have a Jupyter notebook with some cells loaded that include javascript, then that javascript remains when you reload the notebook. The way to get it to be "clean" so that it can find the d3 library again is to go Kernel -> Restart and Clear Output.
from pyzx.
I found I had the same issue (d3 not loading) and in my case it was caused by jupyter notebook
not serving files from hidden folders. The command jupyter notebook --ContentsManager.allow_hidden=True
fixed this issue. It doesn't fix the other issue with jupyter lab
and require
, sadly.
Edit to add: My python virtual environment is held in a folder called .venv
, which is interpreted as a hidden folder because it starts with a .
. Therefore trying to retrieve d3.v5.min.js
from the pyzx library (which is held inside the virtual environment folder) is not allowed by jupyter's file server.
from pyzx.
I think the d3 loading issues have now all been fixed, so I'm closing this issue. Please create a new issue if new problems have arisen.
from pyzx.
Related Issues (20)
- `extract_circuit` does not turn grounds into measurements and classically-conditioned gates HOT 3
- pyzx unable to optimize when circuit contains rx or sx gate HOT 3
- support custom gates with phases HOT 1
- rename `master` branch to `main`
- `pyzx.draw()` does not work in some matplotlib environments HOT 2
- Qiskit 1.0 OpenQASM 3 output breaks `qasmparser` because of spaces between phases
- `U3Gate` is deprecated in Qiskit 1.0, replaced with `UGate`, pyzx needs to handle the new gate
- `pyzx.draw()` is incompatible with dark background HOT 2
- Clifford simp adds a phase of n*pi/2 HOT 2
- Coding style HOT 4
- Boundary pivot is never matched
- Lack of documentation on the preconditions to apply existing transformations
- Clarification on applying individual transformations HOT 5
- Saving/loading is broken for multigraphs
- Methods to convert a graph to tensor/matrix do not work for multigraphs HOT 6
- Add hopf rule and self-loop removal rules for multigraph HOT 2
- Support edge_data dictionary in the graph data structure HOT 3
- Why are there three implementations of every rule: in rules.py, basicrules.py and editor_actions.py? HOT 3
- add_edge with auto_simplify is incorrect in Multigraph
- Make ZX diagram editor compatible with newer version of ipywidgets HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyzx.