Releases: zxcalc/pyzx
v0.8.0
[0.8.0] - 2024-02-14
This release includes breaking changes!
Major new features are support for W-spiders and Z-boxes, which are generators used in certain extensions of the ZX-calculus, such as in this paper which served as the motivation.
It also adds more formal support for symbolic phases through the addition of a Poly
class that can represented polynomial expressions containing Boolean and continuous variables.
These features were implemented to support the development of ZXLive, a new graphical proof assistant for ZX-diagrams.
This release includes some changes that are not backwards compatible. The most important of which is changing how inputs and outputs are stored in the json format. This means that json files produced by Graph.to_json()
are not parsible by older versions, and older versions are no longer parsible by this newer version.
In addition, the gate CX
has been renamed to XCX
to make it more clear that it is in fact not an alternative name for the CNOT
gate. Finally, the FSim
gate now takes as first arguments the control and target, and only then the angles, in order to be consistent with the other gate definitions.
Added
- Support for W nodes and Z boxes (courtesy of @RazinShaikh).
- Support for symbolic phases that can either be Boolean or continuous variables. This is implemented through the new
Poly
class (standing for Polynomial) (courtesy of @RazinShaikh). - Support for Jupyter notebooks in documentation using nbsphinx (courtesy of @dlyongemallo).
- Jupyter notebook documenting all supported gates (courtesy of @dlyongemallo).
- Support for OpenQASM 3.0 (courtesy of @dlyongemallo).
- A function
is_well_formed
to check that a graph is a well-formed ZX-diagram (courtesy of @RazinShaikh). - A function
is_pauli
to check whether a phase is Pauli (courtesy of @y-richie-y). - A function
GraphDiff
that calculates what actions are needed to bring one graph to another (used in ZXLive). - Functions
simplify.to_clifford_normal_form_graph
andextract.extract_clifford_normal_form
. - Lazy import of some dependencies to improve start-up time.
Changed
- Class
CX
, which refers to an X-controlled X gate, renamed toXCX
for clarity. - Parameters for
FSim
changed to put control and target before angles, for consistency with other gates. - json format correctly remembers input/output ordering (older json no longer parsible).
Fixed
- A bunch of mypy issues.
- json export and import supports Poly phases.
- Grounds being dropped during composition and other operations (#177 courtesy of @ABorgna).
- The
tensorfy
function used the visual ordering of inputs and outputs, instead of the correct ordering (#168). - Several qasmparser bugs (courtesy of @dlyongemallo).
- Incorrect gate name when optimization combines phases into single gate (#134 courtesy of @bichselb).
- The gflow function returned a gflow when it shouldn't (#114 courtesy of @mafaldaramoa).
- Error in qasmparser when importing a gate with a negative phase (#112).
Automated changelog from Github
- Fix gflow by @mafaldaramoa in #115
- Fix mypy complaining about incompatible type for Z2 = Literal[0,1]. by @dlyongemallo in #118
- Remove a number of unnecessary "# type: ignores". by @dlyongemallo in #119
- serialize and deserialize GraphDiff by @RazinShaikh in #126
- is_pauli: zxlive symbol support by @y-richie-y in #127
- W node support by @RazinShaikh in #128
- W fusion bug fix by @RazinShaikh in #129
- Match symbolic phase gadgets by @y-richie-y in #132
- Add iterators for
full_reduce
,interior_clifford_simp
andpivot_gadget_simp
by @y-richie-y in #130 - Fix #134: incorrect optimization for qiskit circuit by @bichselb in #135
- Minor improvements to
print_phase
class var ingates.py
. by @dlyongemallo in #136 - Remove some "# type: ignore"s. by @dlyongemallo in #137
- Make
quipper_name
a class var inGate
with a default value ofundefined
. by @dlyongemallo in #141 - Add .venv to .gitignore. by @dlyongemallo in #142
- Rename CX class to XCX to reduce confusion. by @dlyongemallo in #140
- Fix graph diff not serializing phases properly by @RazinShaikh in #144
- Fix a wrong variable used in error message. by @dlyongemallo in #149
- In qasmparser.py, reset the parser state between calls to
parse
. by @dlyongemallo in #150 - Add basic support for OpenQASM 3. by @dlyongemallo in #151
- Change
FSim
by puttingcontrol
andtarget
parameters first. by @dlyongemallo in #154 - Minor cosmetic changes to make codebase more consistent. by @dlyongemallo in #155
- Fix direction of qasm
ry
rotation and addy
gate. by @dlyongemallo in #157 - method to check if the graph is well-formed by @RazinShaikh in #162
- Add notebook support in doc using nbsphinx. by @dlyongemallo in #152
- Add support for most OpenQASM 2 and 3 standard gates. by @dlyongemallo in #156
- Z box by @RazinShaikh in #164
- Use
VertexType
constants in tensor.py. by @dlyongemallo in #170 - Fix a bug where gates with multiple phases did not output the phases … by @dlyongemallo in #172
- Support output to OpenQASM 3 format. by @dlyongemallo in #174
- Make
RZZ
a subclass ofParityPhase
. by @dlyongemallo in #173 - Make the docstring for
graph_to_swaps
a bit clearer. by @dlyongemallo in #175 - Add a script to output PDF in Windows. by @dlyongemallo in #176
- Fix grounds being dropped during composition and other operations by @ABorgna in #178
- More symbolic features for custom rewrites by @RazinShaikh in #181
- typo for pi in jsonparser string_to_phase by @RazinShaikh in #184
- remove redundant tests for
ry
by @dlyongemallo in #183 - Add a Jupyter notebook documenting the supported qasm gates. by @dlyongemallo in #185
- In error message converting parametrized diagram to tensor, display the poly. by @dlyongemallo in #186
- Catch up CHANGELOG. by @dlyongemallo in #188
- Update
Measurement
gate qasm comment and link. by @dlyongemallo in #190 - Document all supported gates in the notebook. by @dlyongemallo in #191
- Fix bug in drawing.py by @BenWillemsen in #194
New Contributors
- @mafaldaramoa made their first contribution in #115
- @dlyongemallo made their first contribution in #118
- @RazinShaikh made their first contribution in #126
- @bichselb made their first contribution in #135
- @BenWillemsen made their first contribution in #194
Full Changelog: v0.7.3...v0.8.0
v0.7.3
[0.7.3] - 2023-02-22
Hotfix for bug Graph.compose()
function. Note that 0.7.2 is a non-functioning release on PyPI.
Fixed
BaseGraph.compose()
now functions as expected.
v0.7.1
[0.7.1] - 2022-02-02
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).
Added
- 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).
Changed
- 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
- Fixed bug in
Circuit.verify_equality
where it would sometimes say that circuits are equal while they are not (courtesy of Julian Verweij).
v0.7.0
[0.7.0] - 2022-02-19
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
- 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.
Changed
Graph.inputs
is now a method that returns a list of inputs, instead ofGraph.inputs
being a list itself. The same forGraph.outputs
.
Fixed
- Several incorrect scalars were fixed in ZH-diagram rewrite rules.
v0.6.4
[0.6.4] - 2021-01-27
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
- 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.
Changed
- 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.
Fixed
- 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.
v0.6.3
[0.6.3] - 2020-12-2
Added
- 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.
Changed
- 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
- Fixed exception in editor that made it unusable.
- Fixed bug when matching parallel Hadamards with match_hadamards().
- Undo in editor correctly remembers scalar.
v0.6.2
Fixed several bugs related to scalars not being remembered or updated correctly. Also added a number of convience functions.
Added
- 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).
Fixed
- basicrules.strong_comp now preserves scalar correctly.
- Undo in editor now remembers scalar correctly.
- bialg and copy rewrites in editor now preserve scalar correctly.
v0.6.0
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.
v0.5.1
Fixed syntax error that prevented scripts from being called
First upload to PyPI
PyZX is now available as a package on PyPI. To install it, run
pip install pyzx