Add new visualization tools#479
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #479 +/- ##
==========================================
+ Coverage 88.75% 89.28% +0.53%
==========================================
Files 46 46
Lines 6749 6841 +92
==========================================
+ Hits 5990 6108 +118
+ Misses 759 733 -26 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| g = flow.correction_function | ||
| # Draw horizontal arrow indicating measurement order with "Layer" label below | ||
| offset = mtransforms.ScaledTranslation(0, -27 / 72, fig.dpi_scale_trans) |
There was a problem hiding this comment.
Maybe better to save for further work later, but I think shifting the layers arrow down a little would be nicer - further from the nodes, and leaving less white space before the border of the plot.
There was a problem hiding this comment.
Mmm, yes, I'm not happy with this solution. It's not super robust: if you tweak the node distance, the arrow can appear outside the plot. I couldn't figure out how to make it work in all cases, but I think that the layer arrow is a nice addition regardless. Maybe we could fill an issue and leave this detail (together with your suggestion) for the backlog?
| # We can't use functools.singledispatch here. | ||
| # If we annotate the dispatch argument with CausalFlow[AbstractPlanarMeasurement] | ||
| # compilation will fail because generic types are only known statically. | ||
| # If we don't specify the generic type (we don't need to), mypy will complain. | ||
|
|
||
| # Circumvent import loop | ||
| from graphix.flow.core import CausalFlow # noqa: PLC0415 | ||
|
|
||
| pos = ( | ||
| _compute_positions_causal_flow(flow) | ||
| if isinstance(flow, CausalFlow) | ||
| else _compute_positions_partial_order(flow) | ||
| ) |
There was a problem hiding this comment.
I am not particularly fond of singledispatch, but if we want to use it here, we can do as I did in this commit (by explicitly passing a type as an argument to register): thierry-martinez@179d683
There was a problem hiding this comment.
Oh very nice, I did't know register accepted arguments. Don't you think it's nicer with singledispatch? It avoids the import inside the function...
There was a problem hiding this comment.
I have no strong opinion on this, but note that we still have import loops with singledispatch. from graphix.flow.core import CausalFlow should be moved to the top level indeed, but that forces GraphVisualizer to be imported inside the draw methods in flow/core.py to break the import loop (though, admittedly, this seems more logical this way). Additionally, I'm not sure what a good name would be for merging _compute_positions_causal_flow and _compute_positions_partial_order (and should we keep _compute_positions_opengraph separate?).
There was a problem hiding this comment.
If we went this way, we could merge all three functions into a single one: _compute_positions. I think it makes sense since these three functions do the same thing (in different ways, suitable for different scenarios), but it may make the code less readable...
…e method. Add local_clifford to visualization options
thierry-martinez
left a comment
There was a problem hiding this comment.
LGTM! Thanks, the visualization API is much better that way!
Co-authored-by: thierry-martinez <thierry.martinez@inria.fr>
This PR adds new visualization methods:
OpenGraph.draw,PauliFlow.drawandXZCorrections.draw. Further, the methodPattern.draw_graphis replaced byPattern.drawwith anannotationsparameter which allows to visualise the underlying open graph, flow or xz corrections.This PR does not modify the core logic of the existing visualization tools. However, two stylistic modifications are made: input nodes are represented with squares instead of red-edge circles and it incorporates the layer visualisation introduced in #444.
TODO
Update README with new figure.