All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog. Right now this project is in Beta and does not yet follow Semantic Versioning. Hence, occasionally changes will be backwards incompatible (although they will all be documented here).
Hotfix for bug Graph.compose()
function
BaseGraph.compose()
now functions as expected.
This release improves support and documentation for routing circuits (courtesy of @aborgna-q). In particular it implements the architecture-aware synthesis technique for phase polynomials of this paper.
The way that the D3 library is loaded is also changed, meaning that the D3 visualization should now work on more systems, in particular on Google Colab. This should also hopefully fix some errors with loading the diagram editor (although this still relies on Jupyter's widget library so that that will only work locally).
- New routing method for phase polynomial circuits
zx.routing.route_phase_poly
adapted from this paper (courtesy of @Aerylia and @aborgna-q). - Support for more architectures in routing library (@Aerylia and @aborgna-q).
- Support for more gates of PyQuil (@Aerylia and @aborgna-q).
- New phase polynomial circuit generation functions
zx.generate.phase_poly
,zx.generate.phase_poly_approximate
andzx.generate.phase_poly_from_gadgets
- New scripts
cnots
andphasepoly
that generates random CNOT and phase polynomial circuits (@aborgna-q). - Basic support for symbolic angles using
sympy
when doing rewriting (courtesy of @y-richie-y). - Support for Quipper files that do not contain the "nocontrol" keyword.
- Added support for
ry
gates in QASM files (courtesy of @mgrzesiuk).
- Requirement of
ipywidgets
has been updated fromipywidgets>= 7.5
toipywidgets>=7.5,<8
as newer version broke the diagram editor. - Script
mapper
has been renamed torouter
.
- Fixed bug in
Circuit.verify_equality
where it would sometimes say that circuits are equal while they are not (courtesy of Julian Verweij).
This release adds several new features: support for evaluating ZX-diagrams as tensor networks using the hypergraph contraction methods of quimb, basic support for interacting with the Rust port of PyZX quizx, support for 'hybrid' ZX-diagrams that contain classical wires and measurements, as well as several heuristics for trying to optimise the CNOT count of a circuit that is to be extracted from a ZX-diagram.
There is one small breaking change, which is that Graph.inputs
and Graph.outputs
are now methods that return a list, instead of being lists themselves.
- Added support for evaluating ZX-diagrams as tensor networks in quimb (courtesy of Paul Tirlisan).
- Added quizx backend for the
Graph
class. Graph
vertices can now carry aground
generator. This makes it possible to represent measurements and classical control in the diagrams. See the accompanying paper (courtesy of ABorgna).- Added
extract.lookahead_extract
that uses heuristics to extract circuit with less CNOT gates (courtesy of VladMoldoveanu). - Added
local_search
submodule for doing simulated annealing on rewrites of a ZX-diagram to try to get it to be extracted with less CNOTS (courtesy of Ryan Krueger). - Added new rewrite rule for ZH-diagrams
hsimplify.par_hbox_intro_simp()
that can remove some H-boxes. - Added several new rewrite rules to
basicrules
andmbqc
. - QASM parser: added support for controlled-Hadamard and controlled-Z phase gates.
- QC parser: added support for SWAP gates (courtesy of wdomitrz).
- Added
Graph.set_inputs()
andGraph.set_outputs()
to set a list of vertices to be the inputs/outputs of a diagram. - Added
Graph.num_inputs()
andGraph.num_outputs()
to get the number of inputs and outputs of a diagram.
Graph.inputs
is now a method that returns a list of inputs, instead ofGraph.inputs
being a list itself. The same forGraph.outputs
.
- Several incorrect scalars were fixed in ZH-diagram rewrite rules.
The main feature added is support for copying and pasting inside the editor. This release should also hopefully fix the issue where users of the PyPI version can't use zx.draw and the editor.
- Added functionality to copy and paste parts of a diagram in the editor.
- qasm files can now include u1/u2/u3 gates.
- Method BaseGraph.merge() to merge two graphs in place.
- Method BaseGraph.subgraph_from_vertices() to get the induced subgraph from a set of vertices.
- tikz_to_graph() is now a bit more versatile in what it accepts as valid phases.
- matrix_to_latex() is slightly more intelligent about parsing numbers.
- Changed colours in editor to match those of zx.draw.
- Decomposing a Hadamard into Euler angles gave wrong scalar.
- Added d3.v5.min.js to the manifest, which hopefully prevents the issue where people using the PyPI version can't see graphs drawn with d3.
- Added settings.drawing_auto_hbox to toggle the default value of auto_hbox when using zx.draw().
- Added function generate.spider to construct a graph containing a single spider.
- Added function Graph.translate(x,y) to translate all the coordinates in the Graph instance by the specified amount.
- Added additional rewrite rule to editor for H-box fusion.
- Added hsimplify.zh_simp() rewrite strategy that does a collection of rewrites of increasing difficulty to simply ZH-diagrams.
- The par_hbox() simplification can now also handle wires with NOTs on them.
- The copy rule in the editor now also understands how to copy a |-> state through an H-box.
- Fixed exception in editor that made it unusable.
- Fixed bug when matching parallel Hadamards with match_hadamards().
- Undo in editor correctly remembers scalar.
- Added extract_simple function as simple method for extracting circuits from ZX-diagrams that have causal flow.
- Added function find_scalar_correction(g1,g2) that gives the correct scalar to make g1 and g2 equal (assuming they represent the same linear map up to a global scalar).
- Added function drawing.graphs_to_gif that takes in a list of Graphs and outputs an animated gif showing them in sequence. Note that this requires imagio to be installed.
- The output classes for each of the vertex and edge types in the methods for converting a Graph to tikz format can now be set using zx.settings.tikz_classes.
- draw_matplotlib, draw_d3 (and hence zx.draw) and editor.edit have additional optional argument show_scalar to display the scalar of the Graph.
- Added argument draw_scalar to all functions converting a Graph into tikz format to toggle the display of the scalar of the Graph in the tikz output.
- The Graph method to_json now remembers the scalar of the graph by default (and Graph.from_json can handle this).
- basicrules.strong_comp now preserves scalar correctly.
- Undo in editor now remembers scalar correctly.
- bialg and copy rewrites in editor now preserve scalar correctly.
- Mac users can now Command-click instead of Ctrl-click in the editor.
- Added
Graph.to_tikz
andGraph.from_tikz
functions in order to convert ZX-diagrams to and from a tikz file. - Can now compose
Graph
instances using the*
operator. - Added function
Graph.add_edge_smart
as a convenience wrapper forGraph.add_edge_table
. - Added
Graph.auto_detect_io
as an alias ofGraph.auto_detect_inputs
, perhaps deprecating the old function at some point. - Added top-level scalar magic constants
ONE, SQRT_TWO, TWO, SQRT_TWO_INV, TWO_INV
in order to more easily set the value ofg.scalar
forGraph
instances.
- Changed default behaviour of
preserve_scalar
argument incompare_tensors
: now always defaults toFalse
. Circuit.verify_equality
now doesn't say SWAP is equal to the identity. Added an argument to get back the original behaviour.- Changed the output of
zx.draw
slightly: more visible labels, more colourblind friendly colours.
- Fixed several bugs in the rewriting with functions in
editor_actions.py
- Fixed bug where Graph.num_edges() wouldn't return correct number of edges.
- Fixed error that occurred when running pyzx from a different drive than the install drive on Windows.
- Fixed several bugs in
hsimplify.hpivot_simp
. - Fixed exception when entering negative phase in editor.
This release has made many backwards incompatible changes to the API in order to remove some old functions and rename other functions to more logical or consistent names. In particular, all British spelling names have been renamed to American spelling names. After this release the API should be significantly more stable.
The license for this project has been changed from GPLv3 to Apache2, in order to streamline the process of using PyZX with other open-source quantum computing projects.
- All functions now have typing hints, and mypy runs successfully on PyZX.
- ZX-diagram editor that runs in a Jupyter notebook. See the documentation for the details.
- New function
zx.matrix_to_latex
to pretty-print a numpy matrix (useful in Jupyter notebook in combination withipywidgets.Label
). - There is now a
zx.settings
object that stores some global values that affect how PyZX draws stuff, and how it interacts with external executables. - Added
zx.draw_d3
andzx.draw_matplotlib
to account for new behaviour ofzx.draw
.
- Circuit extraction algorithm has been updated to use the one from the There and back again paper.
- Main circuit extraction function has been renamed from
zx.extract.streaming_extract
tozx.extract_circuit
. zx.draw
now intelligently changes whether to use d3 or matplotlib. Setting can be changed usingzx.settings.drawing_backend
.- The official language of PyZX is now American English, instead of a mix of British and American english.
g.normalise()
has been renamed tog.normalize()
.g.neighbours()
has been renamed tog.neighbors()
.- The various functions for converting ZX-diagrams into json or other formats now have become methods of the Graph instance themselves. I.e.
g.to_json()
instead ofzx.io.graph_to_json(g)
andGraph.from_json(js)
instead ofzx.io.json_to_graph(js)
. g.auto_detect_inputs()
is now smarter, and turns any boundary node that 'points right' into an input, and similarly for outputs.zx.compare_tensors
now automatically only checks equality up to scalar if one of the arguments is a Circuit.add_edge_table
function inBaseGraph
now supports more operations involving H-boxes, so that ZH-calculus simplifications can apply to more diagrams.- Numerous small bugfixes that were found as a result of mypy type-checking that probably weren't affecting any existing code.
- Several files and functions that weren't being used and only caused confusion to new users, including
phasepoly.py
, and all the*_threaded
functions fromsimplify.py
- Removed support for running PyZX inside of Quantomatic, as this functionality probably didn't work anyway (since PyZX now used Python3 functionality).
zx.d3.draw
is deprecated. Usezx.draw
orzx.draw_d3
instead.zx.extract.streaming_extract
is deprecated. Usezx.extract_circuit
instead.
Hotfix release to fix syntax error that prevented scripts from being called.
First PyPI release.