-
Notifications
You must be signed in to change notification settings - Fork 63
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
Heralds out of their box #207
Comments
I'd like to work on this. I have reproduced the error on a Jupyter notebook. What would be a good starting point to go about solving this? |
I've inspected the code, and I suspect there might be some slight miscalculation in the |
Hello @alt-shreya, thanks for your interest in the issue 👍 ! I believe that the core issue is coming from the fact the heralds are added after the circuit, we would expect them to "push" a bit the top beamsplitter while the circuit is being rendered. However how it is done currently:
Let us know if you can figure this out ! (see @raksharuia for further help) |
Hi @alt-shreya, are you still working on this issue? I'm also interested in this issue but I do not want to disturb you if you are about to figure out. |
hi @king-p3nguin, thank you for checking in. I have been working on it, yes. In all honesty, I haven't figured out the final solution yet, but I'm hoping to take another crack at it. |
Would that be the expected output? I found two other issues in the rendering code:
The fix that generated the diagrams above comes with a caveat: we need two passes over the object graph, one that mimicks the main rendering but just keeps track of potential overlaps between objects (implemented as a |
Hello @burlemarxiste , The graphics you show look nice. That's exactly what's expected. About the issues you've found in the code:
|
You can check my code here. main...burlemarxiste:Perceval:main It includes the implementation of barriers, simply because my initial way of approaching the rendering problem was to create a dummy circuit element that could serve as a spacer. This was a wrong approach, but half of the code for a barrier was done. Things on which I'd appreciate feedback:
I tried to make flake8 as happy as possible with To answer your question about performance, the new implementation of |
I'll check your code soon.
Thanks for your answer on the pre-renderer. |
In order to implement the barriers, I needed an element that had no effect on the states but that could be put in a circuit, that has an x order, that is rendered... so an empty Circuit() couldn't do the trick.
|
Separate branch with only the renderer fix. |
Thanks I'll review it and test it tomorrow. |
Closes #207 * Fix of heralds display * Fixed the missing call to set_background that disappeared during the merge; updated the image for the unit test that checks barriers and heralds in the same drawing; added the checks on the size in the pre-renderer * Fixed rendering when recursive is False * Missing reference image for unit test
Hey @burlemarxiste , closing this issue now and you're assigned to it. You're the UnitaryHack 2024 bounty winner for this issue. |
Describe the bug
Perceval has a renderer at the
Circuit
or theProcessor
level allowing to generate svg or png through matplotlib library. At the processor level, it is possible to add heralds on some modes - as a result, these modes are not anymore available and the heralds are showing inside the circuit.However, the rendering of the circuit does not take these heralds into account which makes sometime the herald appears as overlapping with the circuit box.
To Reproduce
within Pycharm or any editor supporting in-app matplot display, or within a Jupyter notebook
or
Expected behavior
The herald on the first mode should be displayed inside the circuit bounding box
Additional context
In notebook, a svg renderer is used (perceval/rendering/canvas/svg_canvas.py), in editor, matplotlib renderer is used (perceval/rendering/canvas/mplot_canvas.py)
The text was updated successfully, but these errors were encountered: