Skip to content
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

Trapped ion decomposer setup and rotation gates improvement #346

Merged
merged 39 commits into from Jan 14, 2020

Conversation

dbretaud
Copy link
Contributor

@dbretaud dbretaud commented Dec 10, 2019

New setup:
-> new decomposition rules for Hadamard to Rx and Ry
-> new decomposition rules for Rz to Rx and Ry
-> new decomposition rules for CNOT to Rxx, Rx and Ry
-> update on the restrictedgateset setup to allow the call of an external decomposition chooser function
-> new trapped_ion_decomposer setup calling restrictedgateset with Rx,Ry,Rxx and a new decomposition chooser function that chooses decompositions to maximize Ry gate cancellation
-> test functions for decomposition gates ignore global phases when comparing states
Improvement on Rotation gates:
-> is_identity function for every basic gates returning True if gate doesn't do anything. Ex: rotation gates with an angle being 0 or 4pi
-> local optimizer improvement to remove gates equivalent to the Identity gate
-> cosmetic improvements on the angle display for rotation gates for both python string and latex via the to_string() function

Ytterbot and others added 20 commits October 23, 2019 17:22
… include compiler chooser, extension of available decompositions, new setup based on restrictedgateset but adapted for trapped ion configurations
Addition of test file for the rz2rx decomposition and edit to comments in the rz2rx file
Addition of test file for the rz2rx decomposition
Update to comments
Update to comments
Corrected an angle.
Edited comments.
Updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.
…gate

set will fail decomposing into Rxx because of the default chooser
Testing file for cnot2rxx decomposition. Includes updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.
…izer.

basic rotation gates ignore now the global phase and are defined over 0:2pi
Documentation and comments.
@Takishima Takishima self-requested a review December 16, 2019 06:32
Copy link
Collaborator

@Takishima Takishima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear David,

Many thanks for your work in implementing these features for trapped ion system in ProjectQ.

I have gone through the code once and added quite a few comments/changes that I would like addressed before we move forward with this PR. Once these are done, I will go through everything once again to make the finishing touches and then we should be able to merge this into ProjectQ.

In the meantime, I will also arrange for you to sign the CLA.

projectq/ops/_basics_test.py Outdated Show resolved Hide resolved
projectq/ops/_basics.py Outdated Show resolved Hide resolved
projectq/ops/_basics.py Outdated Show resolved Hide resolved
projectq/ops/_basics.py Outdated Show resolved Hide resolved
projectq/ops/_basics.py Outdated Show resolved Hide resolved
projectq/setups/trapped_ion_decomposer.py Outdated Show resolved Hide resolved
projectq/setups/trapped_ion_decomposer.py Outdated Show resolved Hide resolved
projectq/setups/trapped_ion_decomposer.py Outdated Show resolved Hide resolved
projectq/setups/trapped_ion_decomposer.py Outdated Show resolved Hide resolved
projectq/setups/trapped_ion_decomposer.py Outdated Show resolved Hide resolved
projectq/ops/_basics.py Outdated Show resolved Hide resolved
projectq/ops/_basics.py Outdated Show resolved Hide resolved
projectq/ops/_basics.py Outdated Show resolved Hide resolved
Takishima
Takishima previously approved these changes Jan 13, 2020
@Takishima Takishima dismissed their stale review January 13, 2020 13:24

Forgot to add a few more changes

@Takishima
Copy link
Collaborator

I had to fix a few issues here and there to get all the tests to pass and make sure the test coverage was proper, but I will now merge those changes.

Many thanks for taking the time to implement new features into ProjectQ and for signing the CLA.

@Takishima Takishima merged commit 93f2d79 into ProjectQ-Framework:develop Jan 14, 2020
Takishima added a commit that referenced this pull request Mar 19, 2020
* Phase Estimation as a Gate in ops (#260)

* First testing version of Phase Estimation with a lot of hardcoding

* Adapt to All(Measure)

* Adding operators for more than 1 quibit, first version

* Adding operators for more than 1 quibit, first versioni: testing

* Work in progress: create a PhaseX gate to tests via class

* Work in progress: create a PhaseX gate to tests via class. Clean garbaje files

* Work in progress: create a PhaseX gate to tests via class. Some enhanement

* Work in progress: create a PhaseX gate to tests via class. PhaseX testing

* Work in progress: Debugging algorithm

* Work in progress: Debugging algorithm

* Adding 2qubit example

* adding 2 qubit Gate

* Initial version

* Create Phase Estimation as a new Gate in operations

* Solving travis checks

* python 2 compatibility + error in StatePreparation normalization

* test coverage includes now the string

* Improve the check test for no eigenvector test

* Start modifying to decomposition

* QPE as decomposition and gate

* QPE as decomposition and gate: correct a detail in the test

* try to get the travis-ci freeze solved

* Solve a name not defined error in the phaseestimation tests

* Solve coverage in tests

* Address comments in review + change how to assert the tests

* Enhance statistis in the tests bi more executions

* Correct bad calculation in tests

* Refine test

* Address Andi comments: add detail in the examples and atributes and removing code in the test that is never executed

* Correct statistics in qpe test (#328)

* Amplitude Amplification algorithm as a Gate in ops

* Amplitude Amplification algorithm as a Gate in ops, correct test_string_functions

* Amplitude Amplification algorithm as a Gate in ops, correct coverage for _qaagate_test

* Amplitude Amplification algorithm as a Gate in ops, correct test estimation statistics in phaseestimation_test

* Try to triger Travis test because an apt get failure in the travis test

* resend docs/projectq.ops.rst file

* resend file versions previous to AA

* Try to triger Travis test because it never ran

* Try to triger Travis test again to try to get the tests ran

* Amplitude Amplification algorithm as a Gate in ops (#327)

* Amplitude Amplification algorithm as a Gate in ops

* Amplitude Amplification algorithm as a Gate in ops, correct test_string_functions

* Amplitude Amplification algorithm as a Gate in ops, correct coverage for _qaagate_test

* Amplitude Amplification algorithm as a Gate in ops, correct test estimation statistics in phaseestimation_test

* Try to triger Travis test because an apt get failure in the travis test

* Address changes proposed by Damien

* Address changes proposed by Damien, missed one

* Address comments by Damien including eliminate the usage of algorith_inverse and eliminate QPE files form the PR

* Address comments by Damien including eliminate the usage of algorith_inverse and eliminate QPE files form the PR, second try

* Address comments by Damien forgot _qaagate_test

* Update amplitudeamplification_test.py

Wrap lines to 80 characters

* Update amplitudeamplification.py

Wrap lines to 80 characters

* Update _qaagate.py

Minor style correction

* Update amplitudeamplification_test.py

Cleanup imports

* 3 additional 2-qubit gates (#330)

* Modified _gates.py: Documentation, 2-qubit rotations, 1qubit-rotation string attributes.

* Strings of rotation gates fixed.

* Added two-qubit rotation gate tests.

* Resource Counter import Rzz added.

* Added Rzz test and fixed expected outcome.

* removed wrongfully pushed dev gates.

* Update _gates.py

Remove unneeded import

* Removed hardcoded "Phase" name for Ph(angle) gate

* C++ simulator performance improvements (#329)

* C++ simulator performance: make the swap-gate run in native C++

It was defined as a BasicMathGate before which made it run as python
code through the emulate_math_wrapper. The new variant just uses its
matrix representation to run it in native code.

* C++ simulator performance: add dedicated C++ code for common math gates

The BasicMathGate uses a C++ python wrapper (emulate_math_wrapper) to allow generic
calculations which makes it very slow. This detects some math gates and
provides a native C++ implementation for it.

* C++ simulator performance: use larger memory alignment

* C++ simulator performance: recycle large StateVector memory buffers

This avoids costly std::vector copying/reallocations by using some
static std::vector to reuse the allocated buffer (just by std::swap'ing
a vector into a buffer for later use when it would be deallocated
otherwise).

* C++ simulator performance: improve compiler flags

* Add test coverage for constant math emulation

* Revert "Add test coverage for constant math emulation"

This reverts commit 3bb8a2c.

* Add test coverage for constant math emulation

* Update constant math documentation to include list of pre-conditions (#331)

* Allow selection of drawing order in CircuitDrawer (solves #333) (#334)

* included the possibility to draw the gates in the order they were added to the circuit

* edited param names
tests should pass now

* solved comments

* solved comments

* passes tests

* Test for unordered and ordered circuit drawing

* Reindent files in _circuits

* Minor adjustments to _drawer.py

* added test_body_with_drawing_order

* fixed tests and how draw_gates_in_parallel is interpreted

* Fix failing tests with Python 2.7

One test of _to_latex_test.py was failing due to precision issues.

* Trapped ion decomposer setup and rotation gates improvement (#346)

* reduced Ry decomposition : modification of restrictedgateset setup to include compiler chooser, extension of available decompositions, new setup based on restrictedgateset but adapted for trapped ion configurations

* Addition of test file for the rz2rx decomposition

Addition of test file for the rz2rx decomposition and edit to comments in the rz2rx file

* Revert "Addition of test file for the rz2rx decomposition"

This reverts commit 5aab56b.

* Create rz2rx_test file

Addition of test file for the rz2rx decomposition

* Update rz2rx.py

Update to comments

* Update rz2rx_test.py

Update to comments

* Minor update: remove accidental file

* Minor update rz2rx.py

Corrected an angle.

* Minor update rz2rx_test.py

Edited comments.

* Create h2rx_test.py

Updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* Improvement of the decomposition chooser; Note that basic restricted gate
set will fail decomposing into Rxx because of the default chooser

* Updates to h2rx and cnot2rxx

* Create cnot2rxx_test.py

Testing file for cnot2rxx decomposition. Includes updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* basic rotation gates at an angle of 0 or 2pi are removed by the optimizer.
basic rotation gates ignore now the global phase and are defined over 0:2pi

* Update and create trapped_ion_decomposer_test.py

* Minor update

Documentation and comments.

* Update on comments regarding Identity gates

* Changes 1/2 : command can be printed with unicode symbols only via new
to_String method; syntax correction;

* Work in progress, is commutable

* Update to decomposition test files

rz2rx_test now tests each decomposition defined in rz2rx.all_defined_decomposition_rules
Similar for cnot2rxx_test and h2rx_test

* Revert "Work in progress, is commutable"

This reverts commit 27f820c.

* minor fixes; revert rotation gates to [0;4pi)

* fix comments

* Fix a few issues with the trapped-ion setup

- Store the sign of the last Ry gate on an engine-by-engine basis
- Cleanup of some remaining print statements
- Some stylistic issues fixed

* Mostly fixing stylistic issues and some code cleanup

* h2rx decomposition with correct global phase

* cnot2rxx decomposition with correct global phase

* Fix non-ASCII character in cnot2rxx.py

* Fix some more files for non-ASCII characters

* Specify encoding for files with non-ASCII characters

* Fix test errors

* Fix tests for Python 2.7

* Complete code coverage for trapped-ion setup

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Matplotlib drawer backend (#352)

* Adding tutorials directory

* test

* BV Algorithm

* add Matplotlib circuit drawer backend, this version works for H, CNOT, and Multi-CNOT.

* Delete the added unnecessary attributes in Command object

* Create the CircuitDrawerMatplotlib Class to handles drawing with matplotlib

* Deleted tutorials/.gitkeep

* update

* fix measurement gate

* Delete unrelated files.

* fix Toffoli gate position issue and change the qubit position from 'str' to 'int'

* Pytest for drawer_mpl

* Tests for _plot function

* Fix the R(angle) gate drawing

* added test for is_available and QFT gate

* fix drawing distance between gates when gate_length >2

* new test png for pytest mpl

* added Swap gates and CSwap gate with multi-control and multi-target.

* update test and comments

* Address comments in _drawer.py

* Reindent and reformat parts of _drawer.py

* Address comments in _plot.py

- Minor tweaks, code cleanup, rewrites, etc.

* Reindent and reformat _plot.py

* update tests

* Move matplotlib drawer into its own file + add test coverage

* Use regular expressions to rewrite and shorten gate names

* Change internal storage format for CircuitDrawerMatplotlib

* Better graphics and adapt plot functions to new internal format

- Support for new internal format
- Resulting quantum circuit figure whould work better with scaling
- Large quantum circuits will now result in wider figure instead of
  squeezing everything into the default matplotlib size
- Some support for multi-target qubit gates
- General code cleanup
- Dropped support for double lines when qubit is in classical state

* Complete test coverage + add some checks for to_draw() inputs

* Compatibility with matplotlib 2.2.3

* Remove compatibility code for MacOSX.

Use local matplotlibrc if necessary instead.

* Add matplotlib dependency to requirements.txt

* Fix non-UTF8 character in file

* Fix .travis.yml

* Remove unnecessary PNG files

* Add CircuitDrawerMatplotlib to documentation and minor code fix

* Fix docstring for CircuitDrawerMatplotlib

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Ibm backend v2 (solves #318 and #347) (#349)

* reduced Ry decomposition : modification of restrictedgateset setup to include compiler chooser, extension of available decompositions, new setup based on restrictedgateset but adapted for trapped ion configurations

* Addition of test file for the rz2rx decomposition

Addition of test file for the rz2rx decomposition and edit to comments in the rz2rx file

* Revert "Addition of test file for the rz2rx decomposition"

This reverts commit 5aab56b.

* Create rz2rx_test file

Addition of test file for the rz2rx decomposition

* Update rz2rx.py

Update to comments

* Update rz2rx_test.py

Update to comments

* Minor update: remove accidental file

* Minor update rz2rx.py

Corrected an angle.

* Minor update rz2rx_test.py

Edited comments.

* Create h2rx_test.py

Updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* Improvement of the decomposition chooser; Note that basic restricted gate
set will fail decomposing into Rxx because of the default chooser

* Updates to h2rx and cnot2rxx

* Create cnot2rxx_test.py

Testing file for cnot2rxx decomposition. Includes updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* basic rotation gates at an angle of 0 or 2pi are removed by the optimizer.
basic rotation gates ignore now the global phase and are defined over 0:2pi

* Update and create trapped_ion_decomposer_test.py

* Minor update

Documentation and comments.

* Update on comments regarding Identity gates

* Changes 1/2 : command can be printed with unicode symbols only via new
to_String method; syntax correction;

* Work in progress, is commutable

* Update to decomposition test files

rz2rx_test now tests each decomposition defined in rz2rx.all_defined_decomposition_rules
Similar for cnot2rxx_test and h2rx_test

* Revert "Work in progress, is commutable"

This reverts commit 27f820c.

* ibmq fix: projectq uses new ibmq API (no doc available, just look at qiskit). Connection fixed for 5qb devices, the 15qb melbourne device and the
online simulator
coupling map obtained from ibm server instead of being manually written
one setup can be used for the 3 different backend

* minor fixes

* update on the ibm example

* minor fixes; revert rotation gates to [0;4pi)

* fix comments

* fix mapper choice for simulator. added comments

* minor fixes with results, mapper and testing files. Improvement of
get_probabilities

* Revert "Merge branch 'develop' into ibm_V2"

This reverts commit cd0452a, reversing
changes made to 03daf79.

* minor fixes

* bug fix in client test file

* fixing bug and python2.7 compatibility for testing files

* fix errors

* major fix on testing files

* minor fix on comments and python 2.7 compatibility

* fix 'super()' call for python 2.7

* additional tests

* python2.7 fix

* increase coverage, fix a print statement

* Some minor stylistic adjustments

* Reindent files and fix some linting warnings/errors

* Improve test coverage

* Improve code readability

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Automatically generate documentation ReST files (#339)

* Automate generation of documentation ReST files

* Fix error in conf.py

* Adjust .gitignore

* Update setup.py (#337)

* Rewrite setup.py to fix some issues on Mac OSX and some code cleanup

- On Mac OSX with Homebrew, properly find the path to the OpenMP
  library if compiling with clang from Homebrew
- Code cleanup and some reformating

* Remove use of deprecated setuptools.Feature

Now try to compile the C++ simulator and if it fails, simply install
a pure Python package with some warning messages for the user.

* Update documentation to reflect the latest change to setup.py

* Fix error with deleted method of BuildExt

* Remove global COPYING file and move text to setup.py file itself

* Fix compilation issues on MacOS X

* Update .gitignore

* Fix setup.py for Python2 and MacPorts (Mac OS)

* Fix setup.py on Windows

* Some more fixes

* Attempt to fix failing installation on Travis CI

* Fix installation under Linux

* Undo changes in .travis.yml

* Update setup related tutorials

* Fix a few remaining typos.

* Bumped version number to 0.5.0

* Remove unneeded test

* Fix error in examples/ibm.py

* Add documentation for **kwargs for CircuitDrawerMatplotlib

* Update setup.py license header

Co-authored-by: Damian Steiger <damiansteiger@users.noreply.github.com>
Co-authored-by: Fernando <fernandodelaiglesia@users.noreply.github.com>
Co-authored-by: David Wierichs <davidwierichs@gmail.com>
Co-authored-by: Melven Roehrig-Zoellner <Melven.Roehrig-Zoellner@DLR.de>
Co-authored-by: alexandrupaler <alexandrupaler@gmail.com>
Co-authored-by: David Bretaud <40793394+dbretaud@users.noreply.github.com>
Co-authored-by: Cheng Li <lichengchris@gmail.com>
WrathfulSpatula added a commit to vm6502q/ProjectQ that referenced this pull request Apr 19, 2020
* Update to newer RevKit version. (ProjectQ-Framework#271)

* Add VQE example (ProjectQ-Framework#274)

* Update docs of decompositions. (ProjectQ-Framework#281)

* Add FlipBits gate (ProjectQ-Framework#289)

* Fix strings with invalid escape sequences. (ProjectQ-Framework#300)

* Avoid 502 error when waiting for IBM Q results, resolves ProjectQ-Framework#291 (ProjectQ-Framework#294)

* Expose num_retries and interval in IBMBackend (ProjectQ-Framework#295)

* Don't accept controlled single-qubit gates in restricted gate set. (ProjectQ-Framework#301)

* Implement MatrixGate and simplify __eq__ in BasicGate to improve performance (ProjectQ-Framework#288)

* Bumped version number to 0.4.2

* Phase Estimation as a Gate in ops (ProjectQ-Framework#260)

* First testing version of Phase Estimation with a lot of hardcoding

* Adapt to All(Measure)

* Adding operators for more than 1 quibit, first version

* Adding operators for more than 1 quibit, first versioni: testing

* Work in progress: create a PhaseX gate to tests via class

* Work in progress: create a PhaseX gate to tests via class. Clean garbaje files

* Work in progress: create a PhaseX gate to tests via class. Some enhanement

* Work in progress: create a PhaseX gate to tests via class. PhaseX testing

* Work in progress: Debugging algorithm

* Work in progress: Debugging algorithm

* Adding 2qubit example

* adding 2 qubit Gate

* Initial version

* Create Phase Estimation as a new Gate in operations

* Solving travis checks

* python 2 compatibility + error in StatePreparation normalization

* test coverage includes now the string

* Improve the check test for no eigenvector test

* Start modifying to decomposition

* QPE as decomposition and gate

* QPE as decomposition and gate: correct a detail in the test

* try to get the travis-ci freeze solved

* Solve a name not defined error in the phaseestimation tests

* Solve coverage in tests

* Address comments in review + change how to assert the tests

* Enhance statistis in the tests bi more executions

* Correct bad calculation in tests

* Refine test

* Address Andi comments: add detail in the examples and atributes and removing code in the test that is never executed

* Correct statistics in qpe test (ProjectQ-Framework#328)

* Amplitude Amplification algorithm as a Gate in ops

* Amplitude Amplification algorithm as a Gate in ops, correct test_string_functions

* Amplitude Amplification algorithm as a Gate in ops, correct coverage for _qaagate_test

* Amplitude Amplification algorithm as a Gate in ops, correct test estimation statistics in phaseestimation_test

* Try to triger Travis test because an apt get failure in the travis test

* resend docs/projectq.ops.rst file

* resend file versions previous to AA

* Try to triger Travis test because it never ran

* Try to triger Travis test again to try to get the tests ran

* Amplitude Amplification algorithm as a Gate in ops (ProjectQ-Framework#327)

* Amplitude Amplification algorithm as a Gate in ops

* Amplitude Amplification algorithm as a Gate in ops, correct test_string_functions

* Amplitude Amplification algorithm as a Gate in ops, correct coverage for _qaagate_test

* Amplitude Amplification algorithm as a Gate in ops, correct test estimation statistics in phaseestimation_test

* Try to triger Travis test because an apt get failure in the travis test

* Address changes proposed by Damien

* Address changes proposed by Damien, missed one

* Address comments by Damien including eliminate the usage of algorith_inverse and eliminate QPE files form the PR

* Address comments by Damien including eliminate the usage of algorith_inverse and eliminate QPE files form the PR, second try

* Address comments by Damien forgot _qaagate_test

* Update amplitudeamplification_test.py

Wrap lines to 80 characters

* Update amplitudeamplification.py

Wrap lines to 80 characters

* Update _qaagate.py

Minor style correction

* Update amplitudeamplification_test.py

Cleanup imports

* 3 additional 2-qubit gates (ProjectQ-Framework#330)

* Modified _gates.py: Documentation, 2-qubit rotations, 1qubit-rotation string attributes.

* Strings of rotation gates fixed.

* Added two-qubit rotation gate tests.

* Resource Counter import Rzz added.

* Added Rzz test and fixed expected outcome.

* removed wrongfully pushed dev gates.

* Update _gates.py

Remove unneeded import

* Removed hardcoded "Phase" name for Ph(angle) gate

* C++ simulator performance improvements (ProjectQ-Framework#329)

* C++ simulator performance: make the swap-gate run in native C++

It was defined as a BasicMathGate before which made it run as python
code through the emulate_math_wrapper. The new variant just uses its
matrix representation to run it in native code.

* C++ simulator performance: add dedicated C++ code for common math gates

The BasicMathGate uses a C++ python wrapper (emulate_math_wrapper) to allow generic
calculations which makes it very slow. This detects some math gates and
provides a native C++ implementation for it.

* C++ simulator performance: use larger memory alignment

* C++ simulator performance: recycle large StateVector memory buffers

This avoids costly std::vector copying/reallocations by using some
static std::vector to reuse the allocated buffer (just by std::swap'ing
a vector into a buffer for later use when it would be deallocated
otherwise).

* C++ simulator performance: improve compiler flags

* Add test coverage for constant math emulation

* Revert "Add test coverage for constant math emulation"

This reverts commit 3bb8a2c.

* Add test coverage for constant math emulation

* Update constant math documentation to include list of pre-conditions (ProjectQ-Framework#331)

* Allow selection of drawing order in CircuitDrawer (solves ProjectQ-Framework#333) (ProjectQ-Framework#334)

* included the possibility to draw the gates in the order they were added to the circuit

* edited param names
tests should pass now

* solved comments

* solved comments

* passes tests

* Test for unordered and ordered circuit drawing

* Reindent files in _circuits

* Minor adjustments to _drawer.py

* added test_body_with_drawing_order

* fixed tests and how draw_gates_in_parallel is interpreted

* Fix failing tests with Python 2.7

One test of _to_latex_test.py was failing due to precision issues.

* Trapped ion decomposer setup and rotation gates improvement (ProjectQ-Framework#346)

* reduced Ry decomposition : modification of restrictedgateset setup to include compiler chooser, extension of available decompositions, new setup based on restrictedgateset but adapted for trapped ion configurations

* Addition of test file for the rz2rx decomposition

Addition of test file for the rz2rx decomposition and edit to comments in the rz2rx file

* Revert "Addition of test file for the rz2rx decomposition"

This reverts commit 5aab56b.

* Create rz2rx_test file

Addition of test file for the rz2rx decomposition

* Update rz2rx.py

Update to comments

* Update rz2rx_test.py

Update to comments

* Minor update: remove accidental file

* Minor update rz2rx.py

Corrected an angle.

* Minor update rz2rx_test.py

Edited comments.

* Create h2rx_test.py

Updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* Improvement of the decomposition chooser; Note that basic restricted gate
set will fail decomposing into Rxx because of the default chooser

* Updates to h2rx and cnot2rxx

* Create cnot2rxx_test.py

Testing file for cnot2rxx decomposition. Includes updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* basic rotation gates at an angle of 0 or 2pi are removed by the optimizer.
basic rotation gates ignore now the global phase and are defined over 0:2pi

* Update and create trapped_ion_decomposer_test.py

* Minor update

Documentation and comments.

* Update on comments regarding Identity gates

* Changes 1/2 : command can be printed with unicode symbols only via new
to_String method; syntax correction;

* Work in progress, is commutable

* Update to decomposition test files

rz2rx_test now tests each decomposition defined in rz2rx.all_defined_decomposition_rules
Similar for cnot2rxx_test and h2rx_test

* Revert "Work in progress, is commutable"

This reverts commit 27f820c.

* minor fixes; revert rotation gates to [0;4pi)

* fix comments

* Fix a few issues with the trapped-ion setup

- Store the sign of the last Ry gate on an engine-by-engine basis
- Cleanup of some remaining print statements
- Some stylistic issues fixed

* Mostly fixing stylistic issues and some code cleanup

* h2rx decomposition with correct global phase

* cnot2rxx decomposition with correct global phase

* Fix non-ASCII character in cnot2rxx.py

* Fix some more files for non-ASCII characters

* Specify encoding for files with non-ASCII characters

* Fix test errors

* Fix tests for Python 2.7

* Complete code coverage for trapped-ion setup

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Matplotlib drawer backend (ProjectQ-Framework#352)

* Adding tutorials directory

* test

* BV Algorithm

* add Matplotlib circuit drawer backend, this version works for H, CNOT, and Multi-CNOT.

* Delete the added unnecessary attributes in Command object

* Create the CircuitDrawerMatplotlib Class to handles drawing with matplotlib

* Deleted tutorials/.gitkeep

* update

* fix measurement gate

* Delete unrelated files.

* fix Toffoli gate position issue and change the qubit position from 'str' to 'int'

* Pytest for drawer_mpl

* Tests for _plot function

* Fix the R(angle) gate drawing

* added test for is_available and QFT gate

* fix drawing distance between gates when gate_length >2

* new test png for pytest mpl

* added Swap gates and CSwap gate with multi-control and multi-target.

* update test and comments

* Address comments in _drawer.py

* Reindent and reformat parts of _drawer.py

* Address comments in _plot.py

- Minor tweaks, code cleanup, rewrites, etc.

* Reindent and reformat _plot.py

* update tests

* Move matplotlib drawer into its own file + add test coverage

* Use regular expressions to rewrite and shorten gate names

* Change internal storage format for CircuitDrawerMatplotlib

* Better graphics and adapt plot functions to new internal format

- Support for new internal format
- Resulting quantum circuit figure whould work better with scaling
- Large quantum circuits will now result in wider figure instead of
  squeezing everything into the default matplotlib size
- Some support for multi-target qubit gates
- General code cleanup
- Dropped support for double lines when qubit is in classical state

* Complete test coverage + add some checks for to_draw() inputs

* Compatibility with matplotlib 2.2.3

* Remove compatibility code for MacOSX.

Use local matplotlibrc if necessary instead.

* Add matplotlib dependency to requirements.txt

* Fix non-UTF8 character in file

* Fix .travis.yml

* Remove unnecessary PNG files

* Add CircuitDrawerMatplotlib to documentation and minor code fix

* Fix docstring for CircuitDrawerMatplotlib

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Ibm backend v2 (solves ProjectQ-Framework#318 and ProjectQ-Framework#347) (ProjectQ-Framework#349)

* reduced Ry decomposition : modification of restrictedgateset setup to include compiler chooser, extension of available decompositions, new setup based on restrictedgateset but adapted for trapped ion configurations

* Addition of test file for the rz2rx decomposition

Addition of test file for the rz2rx decomposition and edit to comments in the rz2rx file

* Revert "Addition of test file for the rz2rx decomposition"

This reverts commit 5aab56b.

* Create rz2rx_test file

Addition of test file for the rz2rx decomposition

* Update rz2rx.py

Update to comments

* Update rz2rx_test.py

Update to comments

* Minor update: remove accidental file

* Minor update rz2rx.py

Corrected an angle.

* Minor update rz2rx_test.py

Edited comments.

* Create h2rx_test.py

Updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* Improvement of the decomposition chooser; Note that basic restricted gate
set will fail decomposing into Rxx because of the default chooser

* Updates to h2rx and cnot2rxx

* Create cnot2rxx_test.py

Testing file for cnot2rxx decomposition. Includes updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* basic rotation gates at an angle of 0 or 2pi are removed by the optimizer.
basic rotation gates ignore now the global phase and are defined over 0:2pi

* Update and create trapped_ion_decomposer_test.py

* Minor update

Documentation and comments.

* Update on comments regarding Identity gates

* Changes 1/2 : command can be printed with unicode symbols only via new
to_String method; syntax correction;

* Work in progress, is commutable

* Update to decomposition test files

rz2rx_test now tests each decomposition defined in rz2rx.all_defined_decomposition_rules
Similar for cnot2rxx_test and h2rx_test

* Revert "Work in progress, is commutable"

This reverts commit 27f820c.

* ibmq fix: projectq uses new ibmq API (no doc available, just look at qiskit). Connection fixed for 5qb devices, the 15qb melbourne device and the
online simulator
coupling map obtained from ibm server instead of being manually written
one setup can be used for the 3 different backend

* minor fixes

* update on the ibm example

* minor fixes; revert rotation gates to [0;4pi)

* fix comments

* fix mapper choice for simulator. added comments

* minor fixes with results, mapper and testing files. Improvement of
get_probabilities

* Revert "Merge branch 'develop' into ibm_V2"

This reverts commit cd0452a, reversing
changes made to 03daf79.

* minor fixes

* bug fix in client test file

* fixing bug and python2.7 compatibility for testing files

* fix errors

* major fix on testing files

* minor fix on comments and python 2.7 compatibility

* fix 'super()' call for python 2.7

* additional tests

* python2.7 fix

* increase coverage, fix a print statement

* Some minor stylistic adjustments

* Reindent files and fix some linting warnings/errors

* Improve test coverage

* Improve code readability

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Automatically generate documentation ReST files (ProjectQ-Framework#339)

* Automate generation of documentation ReST files

* Fix error in conf.py

* Adjust .gitignore

* Update setup.py (ProjectQ-Framework#337)

* Rewrite setup.py to fix some issues on Mac OSX and some code cleanup

- On Mac OSX with Homebrew, properly find the path to the OpenMP
  library if compiling with clang from Homebrew
- Code cleanup and some reformating

* Remove use of deprecated setuptools.Feature

Now try to compile the C++ simulator and if it fails, simply install
a pure Python package with some warning messages for the user.

* Update documentation to reflect the latest change to setup.py

* Fix error with deleted method of BuildExt

* Remove global COPYING file and move text to setup.py file itself

* Fix compilation issues on MacOS X

* Update .gitignore

* Fix setup.py for Python2 and MacPorts (Mac OS)

* Fix setup.py on Windows

* Some more fixes

* Attempt to fix failing installation on Travis CI

* Fix installation under Linux

* Undo changes in .travis.yml

* Update setup related tutorials

* Fix a few remaining typos.

* ProjectQ v0.5.0 (ProjectQ-Framework#356)

* Bumped version number to 0.5.0

* Remove unneeded test

* Fix error in examples/ibm.py

* Add documentation for **kwargs for CircuitDrawerMatplotlib

* Update setup.py license header

Co-authored-by: Damian Steiger <damiansteiger@users.noreply.github.com>

* Fix generated documentation (ProjectQ-Framework#360)

* Fix some issues with builtin modules and fix some warnings

* Move generated documentation files into dedicated folder

Co-authored-by: Damien Nguyen <damien1@huawei.com>

* Fix bugs with matplotlib drawer (ProjectQ-Framework#361)

* Accept keywords arguments for Matplotlib drawing

* fix circ drawer when depth == 1

Co-authored-by: Damien Nguyen <damien1@huawei.com>

Co-authored-by: Damian Steiger <damiansteiger@users.noreply.github.com>
Co-authored-by: Mathias Soeken <mathias.soeken@gmail.com>
Co-authored-by: Christian Gogolin <git@cgogolin.de>
Co-authored-by: Thomas Haener <thomashaener@users.noreply.github.com>
Co-authored-by: Damian S. Steiger <dsteiger@phys.ethz.ch>
Co-authored-by: Fernando <fernandodelaiglesia@users.noreply.github.com>
Co-authored-by: David Wierichs <davidwierichs@gmail.com>
Co-authored-by: Melven Roehrig-Zoellner <Melven.Roehrig-Zoellner@DLR.de>
Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>
Co-authored-by: alexandrupaler <alexandrupaler@gmail.com>
Co-authored-by: David Bretaud <40793394+dbretaud@users.noreply.github.com>
Co-authored-by: Cheng Li <lichengchris@gmail.com>
Co-authored-by: Nguyen Damien <damien1@huawei.com>
Co-authored-by: Ari Jordan <56979766+AriJordan@users.noreply.github.com>
WrathfulSpatula added a commit to vm6502q/ProjectQ that referenced this pull request Apr 19, 2020
* Merge from upstream (#15)

* Update to newer RevKit version. (ProjectQ-Framework#271)

* Add VQE example (ProjectQ-Framework#274)

* Update docs of decompositions. (ProjectQ-Framework#281)

* Add FlipBits gate (ProjectQ-Framework#289)

* Fix strings with invalid escape sequences. (ProjectQ-Framework#300)

* Avoid 502 error when waiting for IBM Q results, resolves ProjectQ-Framework#291 (ProjectQ-Framework#294)

* Expose num_retries and interval in IBMBackend (ProjectQ-Framework#295)

* Don't accept controlled single-qubit gates in restricted gate set. (ProjectQ-Framework#301)

* Implement MatrixGate and simplify __eq__ in BasicGate to improve performance (ProjectQ-Framework#288)

* Bumped version number to 0.4.2

* Phase Estimation as a Gate in ops (ProjectQ-Framework#260)

* First testing version of Phase Estimation with a lot of hardcoding

* Adapt to All(Measure)

* Adding operators for more than 1 quibit, first version

* Adding operators for more than 1 quibit, first versioni: testing

* Work in progress: create a PhaseX gate to tests via class

* Work in progress: create a PhaseX gate to tests via class. Clean garbaje files

* Work in progress: create a PhaseX gate to tests via class. Some enhanement

* Work in progress: create a PhaseX gate to tests via class. PhaseX testing

* Work in progress: Debugging algorithm

* Work in progress: Debugging algorithm

* Adding 2qubit example

* adding 2 qubit Gate

* Initial version

* Create Phase Estimation as a new Gate in operations

* Solving travis checks

* python 2 compatibility + error in StatePreparation normalization

* test coverage includes now the string

* Improve the check test for no eigenvector test

* Start modifying to decomposition

* QPE as decomposition and gate

* QPE as decomposition and gate: correct a detail in the test

* try to get the travis-ci freeze solved

* Solve a name not defined error in the phaseestimation tests

* Solve coverage in tests

* Address comments in review + change how to assert the tests

* Enhance statistis in the tests bi more executions

* Correct bad calculation in tests

* Refine test

* Address Andi comments: add detail in the examples and atributes and removing code in the test that is never executed

* Correct statistics in qpe test (ProjectQ-Framework#328)

* Amplitude Amplification algorithm as a Gate in ops

* Amplitude Amplification algorithm as a Gate in ops, correct test_string_functions

* Amplitude Amplification algorithm as a Gate in ops, correct coverage for _qaagate_test

* Amplitude Amplification algorithm as a Gate in ops, correct test estimation statistics in phaseestimation_test

* Try to triger Travis test because an apt get failure in the travis test

* resend docs/projectq.ops.rst file

* resend file versions previous to AA

* Try to triger Travis test because it never ran

* Try to triger Travis test again to try to get the tests ran

* Amplitude Amplification algorithm as a Gate in ops (ProjectQ-Framework#327)

* Amplitude Amplification algorithm as a Gate in ops

* Amplitude Amplification algorithm as a Gate in ops, correct test_string_functions

* Amplitude Amplification algorithm as a Gate in ops, correct coverage for _qaagate_test

* Amplitude Amplification algorithm as a Gate in ops, correct test estimation statistics in phaseestimation_test

* Try to triger Travis test because an apt get failure in the travis test

* Address changes proposed by Damien

* Address changes proposed by Damien, missed one

* Address comments by Damien including eliminate the usage of algorith_inverse and eliminate QPE files form the PR

* Address comments by Damien including eliminate the usage of algorith_inverse and eliminate QPE files form the PR, second try

* Address comments by Damien forgot _qaagate_test

* Update amplitudeamplification_test.py

Wrap lines to 80 characters

* Update amplitudeamplification.py

Wrap lines to 80 characters

* Update _qaagate.py

Minor style correction

* Update amplitudeamplification_test.py

Cleanup imports

* 3 additional 2-qubit gates (ProjectQ-Framework#330)

* Modified _gates.py: Documentation, 2-qubit rotations, 1qubit-rotation string attributes.

* Strings of rotation gates fixed.

* Added two-qubit rotation gate tests.

* Resource Counter import Rzz added.

* Added Rzz test and fixed expected outcome.

* removed wrongfully pushed dev gates.

* Update _gates.py

Remove unneeded import

* Removed hardcoded "Phase" name for Ph(angle) gate

* C++ simulator performance improvements (ProjectQ-Framework#329)

* C++ simulator performance: make the swap-gate run in native C++

It was defined as a BasicMathGate before which made it run as python
code through the emulate_math_wrapper. The new variant just uses its
matrix representation to run it in native code.

* C++ simulator performance: add dedicated C++ code for common math gates

The BasicMathGate uses a C++ python wrapper (emulate_math_wrapper) to allow generic
calculations which makes it very slow. This detects some math gates and
provides a native C++ implementation for it.

* C++ simulator performance: use larger memory alignment

* C++ simulator performance: recycle large StateVector memory buffers

This avoids costly std::vector copying/reallocations by using some
static std::vector to reuse the allocated buffer (just by std::swap'ing
a vector into a buffer for later use when it would be deallocated
otherwise).

* C++ simulator performance: improve compiler flags

* Add test coverage for constant math emulation

* Revert "Add test coverage for constant math emulation"

This reverts commit 3bb8a2c.

* Add test coverage for constant math emulation

* Update constant math documentation to include list of pre-conditions (ProjectQ-Framework#331)

* Allow selection of drawing order in CircuitDrawer (solves ProjectQ-Framework#333) (ProjectQ-Framework#334)

* included the possibility to draw the gates in the order they were added to the circuit

* edited param names
tests should pass now

* solved comments

* solved comments

* passes tests

* Test for unordered and ordered circuit drawing

* Reindent files in _circuits

* Minor adjustments to _drawer.py

* added test_body_with_drawing_order

* fixed tests and how draw_gates_in_parallel is interpreted

* Fix failing tests with Python 2.7

One test of _to_latex_test.py was failing due to precision issues.

* Trapped ion decomposer setup and rotation gates improvement (ProjectQ-Framework#346)

* reduced Ry decomposition : modification of restrictedgateset setup to include compiler chooser, extension of available decompositions, new setup based on restrictedgateset but adapted for trapped ion configurations

* Addition of test file for the rz2rx decomposition

Addition of test file for the rz2rx decomposition and edit to comments in the rz2rx file

* Revert "Addition of test file for the rz2rx decomposition"

This reverts commit 5aab56b.

* Create rz2rx_test file

Addition of test file for the rz2rx decomposition

* Update rz2rx.py

Update to comments

* Update rz2rx_test.py

Update to comments

* Minor update: remove accidental file

* Minor update rz2rx.py

Corrected an angle.

* Minor update rz2rx_test.py

Edited comments.

* Create h2rx_test.py

Updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* Improvement of the decomposition chooser; Note that basic restricted gate
set will fail decomposing into Rxx because of the default chooser

* Updates to h2rx and cnot2rxx

* Create cnot2rxx_test.py

Testing file for cnot2rxx decomposition. Includes updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* basic rotation gates at an angle of 0 or 2pi are removed by the optimizer.
basic rotation gates ignore now the global phase and are defined over 0:2pi

* Update and create trapped_ion_decomposer_test.py

* Minor update

Documentation and comments.

* Update on comments regarding Identity gates

* Changes 1/2 : command can be printed with unicode symbols only via new
to_String method; syntax correction;

* Work in progress, is commutable

* Update to decomposition test files

rz2rx_test now tests each decomposition defined in rz2rx.all_defined_decomposition_rules
Similar for cnot2rxx_test and h2rx_test

* Revert "Work in progress, is commutable"

This reverts commit 27f820c.

* minor fixes; revert rotation gates to [0;4pi)

* fix comments

* Fix a few issues with the trapped-ion setup

- Store the sign of the last Ry gate on an engine-by-engine basis
- Cleanup of some remaining print statements
- Some stylistic issues fixed

* Mostly fixing stylistic issues and some code cleanup

* h2rx decomposition with correct global phase

* cnot2rxx decomposition with correct global phase

* Fix non-ASCII character in cnot2rxx.py

* Fix some more files for non-ASCII characters

* Specify encoding for files with non-ASCII characters

* Fix test errors

* Fix tests for Python 2.7

* Complete code coverage for trapped-ion setup

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Matplotlib drawer backend (ProjectQ-Framework#352)

* Adding tutorials directory

* test

* BV Algorithm

* add Matplotlib circuit drawer backend, this version works for H, CNOT, and Multi-CNOT.

* Delete the added unnecessary attributes in Command object

* Create the CircuitDrawerMatplotlib Class to handles drawing with matplotlib

* Deleted tutorials/.gitkeep

* update

* fix measurement gate

* Delete unrelated files.

* fix Toffoli gate position issue and change the qubit position from 'str' to 'int'

* Pytest for drawer_mpl

* Tests for _plot function

* Fix the R(angle) gate drawing

* added test for is_available and QFT gate

* fix drawing distance between gates when gate_length >2

* new test png for pytest mpl

* added Swap gates and CSwap gate with multi-control and multi-target.

* update test and comments

* Address comments in _drawer.py

* Reindent and reformat parts of _drawer.py

* Address comments in _plot.py

- Minor tweaks, code cleanup, rewrites, etc.

* Reindent and reformat _plot.py

* update tests

* Move matplotlib drawer into its own file + add test coverage

* Use regular expressions to rewrite and shorten gate names

* Change internal storage format for CircuitDrawerMatplotlib

* Better graphics and adapt plot functions to new internal format

- Support for new internal format
- Resulting quantum circuit figure whould work better with scaling
- Large quantum circuits will now result in wider figure instead of
  squeezing everything into the default matplotlib size
- Some support for multi-target qubit gates
- General code cleanup
- Dropped support for double lines when qubit is in classical state

* Complete test coverage + add some checks for to_draw() inputs

* Compatibility with matplotlib 2.2.3

* Remove compatibility code for MacOSX.

Use local matplotlibrc if necessary instead.

* Add matplotlib dependency to requirements.txt

* Fix non-UTF8 character in file

* Fix .travis.yml

* Remove unnecessary PNG files

* Add CircuitDrawerMatplotlib to documentation and minor code fix

* Fix docstring for CircuitDrawerMatplotlib

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Ibm backend v2 (solves ProjectQ-Framework#318 and ProjectQ-Framework#347) (ProjectQ-Framework#349)

* reduced Ry decomposition : modification of restrictedgateset setup to include compiler chooser, extension of available decompositions, new setup based on restrictedgateset but adapted for trapped ion configurations

* Addition of test file for the rz2rx decomposition

Addition of test file for the rz2rx decomposition and edit to comments in the rz2rx file

* Revert "Addition of test file for the rz2rx decomposition"

This reverts commit 5aab56b.

* Create rz2rx_test file

Addition of test file for the rz2rx decomposition

* Update rz2rx.py

Update to comments

* Update rz2rx_test.py

Update to comments

* Minor update: remove accidental file

* Minor update rz2rx.py

Corrected an angle.

* Minor update rz2rx_test.py

Edited comments.

* Create h2rx_test.py

Updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* Improvement of the decomposition chooser; Note that basic restricted gate
set will fail decomposing into Rxx because of the default chooser

* Updates to h2rx and cnot2rxx

* Create cnot2rxx_test.py

Testing file for cnot2rxx decomposition. Includes updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* basic rotation gates at an angle of 0 or 2pi are removed by the optimizer.
basic rotation gates ignore now the global phase and are defined over 0:2pi

* Update and create trapped_ion_decomposer_test.py

* Minor update

Documentation and comments.

* Update on comments regarding Identity gates

* Changes 1/2 : command can be printed with unicode symbols only via new
to_String method; syntax correction;

* Work in progress, is commutable

* Update to decomposition test files

rz2rx_test now tests each decomposition defined in rz2rx.all_defined_decomposition_rules
Similar for cnot2rxx_test and h2rx_test

* Revert "Work in progress, is commutable"

This reverts commit 27f820c.

* ibmq fix: projectq uses new ibmq API (no doc available, just look at qiskit). Connection fixed for 5qb devices, the 15qb melbourne device and the
online simulator
coupling map obtained from ibm server instead of being manually written
one setup can be used for the 3 different backend

* minor fixes

* update on the ibm example

* minor fixes; revert rotation gates to [0;4pi)

* fix comments

* fix mapper choice for simulator. added comments

* minor fixes with results, mapper and testing files. Improvement of
get_probabilities

* Revert "Merge branch 'develop' into ibm_V2"

This reverts commit cd0452a, reversing
changes made to 03daf79.

* minor fixes

* bug fix in client test file

* fixing bug and python2.7 compatibility for testing files

* fix errors

* major fix on testing files

* minor fix on comments and python 2.7 compatibility

* fix 'super()' call for python 2.7

* additional tests

* python2.7 fix

* increase coverage, fix a print statement

* Some minor stylistic adjustments

* Reindent files and fix some linting warnings/errors

* Improve test coverage

* Improve code readability

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Automatically generate documentation ReST files (ProjectQ-Framework#339)

* Automate generation of documentation ReST files

* Fix error in conf.py

* Adjust .gitignore

* Update setup.py (ProjectQ-Framework#337)

* Rewrite setup.py to fix some issues on Mac OSX and some code cleanup

- On Mac OSX with Homebrew, properly find the path to the OpenMP
  library if compiling with clang from Homebrew
- Code cleanup and some reformating

* Remove use of deprecated setuptools.Feature

Now try to compile the C++ simulator and if it fails, simply install
a pure Python package with some warning messages for the user.

* Update documentation to reflect the latest change to setup.py

* Fix error with deleted method of BuildExt

* Remove global COPYING file and move text to setup.py file itself

* Fix compilation issues on MacOS X

* Update .gitignore

* Fix setup.py for Python2 and MacPorts (Mac OS)

* Fix setup.py on Windows

* Some more fixes

* Attempt to fix failing installation on Travis CI

* Fix installation under Linux

* Undo changes in .travis.yml

* Update setup related tutorials

* Fix a few remaining typos.

* ProjectQ v0.5.0 (ProjectQ-Framework#356)

* Bumped version number to 0.5.0

* Remove unneeded test

* Fix error in examples/ibm.py

* Add documentation for **kwargs for CircuitDrawerMatplotlib

* Update setup.py license header

Co-authored-by: Damian Steiger <damiansteiger@users.noreply.github.com>

* Fix generated documentation (ProjectQ-Framework#360)

* Fix some issues with builtin modules and fix some warnings

* Move generated documentation files into dedicated folder

Co-authored-by: Damien Nguyen <damien1@huawei.com>

* Fix bugs with matplotlib drawer (ProjectQ-Framework#361)

* Accept keywords arguments for Matplotlib drawing

* fix circ drawer when depth == 1

Co-authored-by: Damien Nguyen <damien1@huawei.com>

Co-authored-by: Damian Steiger <damiansteiger@users.noreply.github.com>
Co-authored-by: Mathias Soeken <mathias.soeken@gmail.com>
Co-authored-by: Christian Gogolin <git@cgogolin.de>
Co-authored-by: Thomas Haener <thomashaener@users.noreply.github.com>
Co-authored-by: Damian S. Steiger <dsteiger@phys.ethz.ch>
Co-authored-by: Fernando <fernandodelaiglesia@users.noreply.github.com>
Co-authored-by: David Wierichs <davidwierichs@gmail.com>
Co-authored-by: Melven Roehrig-Zoellner <Melven.Roehrig-Zoellner@DLR.de>
Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>
Co-authored-by: alexandrupaler <alexandrupaler@gmail.com>
Co-authored-by: David Bretaud <40793394+dbretaud@users.noreply.github.com>
Co-authored-by: Cheng Li <lichengchris@gmail.com>
Co-authored-by: Nguyen Damien <damien1@huawei.com>
Co-authored-by: Ari Jordan <56979766+AriJordan@users.noreply.github.com>

* Passing unit tests

Co-authored-by: Damian Steiger <damiansteiger@users.noreply.github.com>
Co-authored-by: Mathias Soeken <mathias.soeken@gmail.com>
Co-authored-by: Christian Gogolin <git@cgogolin.de>
Co-authored-by: Thomas Haener <thomashaener@users.noreply.github.com>
Co-authored-by: Damian S. Steiger <dsteiger@phys.ethz.ch>
Co-authored-by: Fernando <fernandodelaiglesia@users.noreply.github.com>
Co-authored-by: David Wierichs <davidwierichs@gmail.com>
Co-authored-by: Melven Roehrig-Zoellner <Melven.Roehrig-Zoellner@DLR.de>
Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>
Co-authored-by: alexandrupaler <alexandrupaler@gmail.com>
Co-authored-by: David Bretaud <40793394+dbretaud@users.noreply.github.com>
Co-authored-by: Cheng Li <lichengchris@gmail.com>
Co-authored-by: Nguyen Damien <damien1@huawei.com>
Co-authored-by: Ari Jordan <56979766+AriJordan@users.noreply.github.com>
WrathfulSpatula added a commit to vm6502q/ProjectQ that referenced this pull request Apr 19, 2020
* Testing tolerance

* Testing tolerance

* Disabling state prep test for 4 qubits

* Tolerance on uniformly controlled gates, and temporarily disabling Python simulator test

* Updating Travis

* Init empty simulator list

* QPE() tolerances

* Phase tolerance

* Uni. Ctrld. amplitude agnostic unit test

* New normalization API

* Optional xFail on QPE tests, after long history of problems

* Time evolution decomposition arbitrary phase factors

* Revert last commit

* Merge from upstream (#15)

* Update to newer RevKit version. (ProjectQ-Framework#271)

* Add VQE example (ProjectQ-Framework#274)

* Update docs of decompositions. (ProjectQ-Framework#281)

* Add FlipBits gate (ProjectQ-Framework#289)

* Fix strings with invalid escape sequences. (ProjectQ-Framework#300)

* Avoid 502 error when waiting for IBM Q results, resolves ProjectQ-Framework#291 (ProjectQ-Framework#294)

* Expose num_retries and interval in IBMBackend (ProjectQ-Framework#295)

* Don't accept controlled single-qubit gates in restricted gate set. (ProjectQ-Framework#301)

* Implement MatrixGate and simplify __eq__ in BasicGate to improve performance (ProjectQ-Framework#288)

* Bumped version number to 0.4.2

* Phase Estimation as a Gate in ops (ProjectQ-Framework#260)

* First testing version of Phase Estimation with a lot of hardcoding

* Adapt to All(Measure)

* Adding operators for more than 1 quibit, first version

* Adding operators for more than 1 quibit, first versioni: testing

* Work in progress: create a PhaseX gate to tests via class

* Work in progress: create a PhaseX gate to tests via class. Clean garbaje files

* Work in progress: create a PhaseX gate to tests via class. Some enhanement

* Work in progress: create a PhaseX gate to tests via class. PhaseX testing

* Work in progress: Debugging algorithm

* Work in progress: Debugging algorithm

* Adding 2qubit example

* adding 2 qubit Gate

* Initial version

* Create Phase Estimation as a new Gate in operations

* Solving travis checks

* python 2 compatibility + error in StatePreparation normalization

* test coverage includes now the string

* Improve the check test for no eigenvector test

* Start modifying to decomposition

* QPE as decomposition and gate

* QPE as decomposition and gate: correct a detail in the test

* try to get the travis-ci freeze solved

* Solve a name not defined error in the phaseestimation tests

* Solve coverage in tests

* Address comments in review + change how to assert the tests

* Enhance statistis in the tests bi more executions

* Correct bad calculation in tests

* Refine test

* Address Andi comments: add detail in the examples and atributes and removing code in the test that is never executed

* Correct statistics in qpe test (ProjectQ-Framework#328)

* Amplitude Amplification algorithm as a Gate in ops

* Amplitude Amplification algorithm as a Gate in ops, correct test_string_functions

* Amplitude Amplification algorithm as a Gate in ops, correct coverage for _qaagate_test

* Amplitude Amplification algorithm as a Gate in ops, correct test estimation statistics in phaseestimation_test

* Try to triger Travis test because an apt get failure in the travis test

* resend docs/projectq.ops.rst file

* resend file versions previous to AA

* Try to triger Travis test because it never ran

* Try to triger Travis test again to try to get the tests ran

* Amplitude Amplification algorithm as a Gate in ops (ProjectQ-Framework#327)

* Amplitude Amplification algorithm as a Gate in ops

* Amplitude Amplification algorithm as a Gate in ops, correct test_string_functions

* Amplitude Amplification algorithm as a Gate in ops, correct coverage for _qaagate_test

* Amplitude Amplification algorithm as a Gate in ops, correct test estimation statistics in phaseestimation_test

* Try to triger Travis test because an apt get failure in the travis test

* Address changes proposed by Damien

* Address changes proposed by Damien, missed one

* Address comments by Damien including eliminate the usage of algorith_inverse and eliminate QPE files form the PR

* Address comments by Damien including eliminate the usage of algorith_inverse and eliminate QPE files form the PR, second try

* Address comments by Damien forgot _qaagate_test

* Update amplitudeamplification_test.py

Wrap lines to 80 characters

* Update amplitudeamplification.py

Wrap lines to 80 characters

* Update _qaagate.py

Minor style correction

* Update amplitudeamplification_test.py

Cleanup imports

* 3 additional 2-qubit gates (ProjectQ-Framework#330)

* Modified _gates.py: Documentation, 2-qubit rotations, 1qubit-rotation string attributes.

* Strings of rotation gates fixed.

* Added two-qubit rotation gate tests.

* Resource Counter import Rzz added.

* Added Rzz test and fixed expected outcome.

* removed wrongfully pushed dev gates.

* Update _gates.py

Remove unneeded import

* Removed hardcoded "Phase" name for Ph(angle) gate

* C++ simulator performance improvements (ProjectQ-Framework#329)

* C++ simulator performance: make the swap-gate run in native C++

It was defined as a BasicMathGate before which made it run as python
code through the emulate_math_wrapper. The new variant just uses its
matrix representation to run it in native code.

* C++ simulator performance: add dedicated C++ code for common math gates

The BasicMathGate uses a C++ python wrapper (emulate_math_wrapper) to allow generic
calculations which makes it very slow. This detects some math gates and
provides a native C++ implementation for it.

* C++ simulator performance: use larger memory alignment

* C++ simulator performance: recycle large StateVector memory buffers

This avoids costly std::vector copying/reallocations by using some
static std::vector to reuse the allocated buffer (just by std::swap'ing
a vector into a buffer for later use when it would be deallocated
otherwise).

* C++ simulator performance: improve compiler flags

* Add test coverage for constant math emulation

* Revert "Add test coverage for constant math emulation"

This reverts commit 3bb8a2c.

* Add test coverage for constant math emulation

* Update constant math documentation to include list of pre-conditions (ProjectQ-Framework#331)

* Allow selection of drawing order in CircuitDrawer (solves ProjectQ-Framework#333) (ProjectQ-Framework#334)

* included the possibility to draw the gates in the order they were added to the circuit

* edited param names
tests should pass now

* solved comments

* solved comments

* passes tests

* Test for unordered and ordered circuit drawing

* Reindent files in _circuits

* Minor adjustments to _drawer.py

* added test_body_with_drawing_order

* fixed tests and how draw_gates_in_parallel is interpreted

* Fix failing tests with Python 2.7

One test of _to_latex_test.py was failing due to precision issues.

* Trapped ion decomposer setup and rotation gates improvement (ProjectQ-Framework#346)

* reduced Ry decomposition : modification of restrictedgateset setup to include compiler chooser, extension of available decompositions, new setup based on restrictedgateset but adapted for trapped ion configurations

* Addition of test file for the rz2rx decomposition

Addition of test file for the rz2rx decomposition and edit to comments in the rz2rx file

* Revert "Addition of test file for the rz2rx decomposition"

This reverts commit 5aab56b.

* Create rz2rx_test file

Addition of test file for the rz2rx decomposition

* Update rz2rx.py

Update to comments

* Update rz2rx_test.py

Update to comments

* Minor update: remove accidental file

* Minor update rz2rx.py

Corrected an angle.

* Minor update rz2rx_test.py

Edited comments.

* Create h2rx_test.py

Updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* Improvement of the decomposition chooser; Note that basic restricted gate
set will fail decomposing into Rxx because of the default chooser

* Updates to h2rx and cnot2rxx

* Create cnot2rxx_test.py

Testing file for cnot2rxx decomposition. Includes updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* basic rotation gates at an angle of 0 or 2pi are removed by the optimizer.
basic rotation gates ignore now the global phase and are defined over 0:2pi

* Update and create trapped_ion_decomposer_test.py

* Minor update

Documentation and comments.

* Update on comments regarding Identity gates

* Changes 1/2 : command can be printed with unicode symbols only via new
to_String method; syntax correction;

* Work in progress, is commutable

* Update to decomposition test files

rz2rx_test now tests each decomposition defined in rz2rx.all_defined_decomposition_rules
Similar for cnot2rxx_test and h2rx_test

* Revert "Work in progress, is commutable"

This reverts commit 27f820c.

* minor fixes; revert rotation gates to [0;4pi)

* fix comments

* Fix a few issues with the trapped-ion setup

- Store the sign of the last Ry gate on an engine-by-engine basis
- Cleanup of some remaining print statements
- Some stylistic issues fixed

* Mostly fixing stylistic issues and some code cleanup

* h2rx decomposition with correct global phase

* cnot2rxx decomposition with correct global phase

* Fix non-ASCII character in cnot2rxx.py

* Fix some more files for non-ASCII characters

* Specify encoding for files with non-ASCII characters

* Fix test errors

* Fix tests for Python 2.7

* Complete code coverage for trapped-ion setup

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Matplotlib drawer backend (ProjectQ-Framework#352)

* Adding tutorials directory

* test

* BV Algorithm

* add Matplotlib circuit drawer backend, this version works for H, CNOT, and Multi-CNOT.

* Delete the added unnecessary attributes in Command object

* Create the CircuitDrawerMatplotlib Class to handles drawing with matplotlib

* Deleted tutorials/.gitkeep

* update

* fix measurement gate

* Delete unrelated files.

* fix Toffoli gate position issue and change the qubit position from 'str' to 'int'

* Pytest for drawer_mpl

* Tests for _plot function

* Fix the R(angle) gate drawing

* added test for is_available and QFT gate

* fix drawing distance between gates when gate_length >2

* new test png for pytest mpl

* added Swap gates and CSwap gate with multi-control and multi-target.

* update test and comments

* Address comments in _drawer.py

* Reindent and reformat parts of _drawer.py

* Address comments in _plot.py

- Minor tweaks, code cleanup, rewrites, etc.

* Reindent and reformat _plot.py

* update tests

* Move matplotlib drawer into its own file + add test coverage

* Use regular expressions to rewrite and shorten gate names

* Change internal storage format for CircuitDrawerMatplotlib

* Better graphics and adapt plot functions to new internal format

- Support for new internal format
- Resulting quantum circuit figure whould work better with scaling
- Large quantum circuits will now result in wider figure instead of
  squeezing everything into the default matplotlib size
- Some support for multi-target qubit gates
- General code cleanup
- Dropped support for double lines when qubit is in classical state

* Complete test coverage + add some checks for to_draw() inputs

* Compatibility with matplotlib 2.2.3

* Remove compatibility code for MacOSX.

Use local matplotlibrc if necessary instead.

* Add matplotlib dependency to requirements.txt

* Fix non-UTF8 character in file

* Fix .travis.yml

* Remove unnecessary PNG files

* Add CircuitDrawerMatplotlib to documentation and minor code fix

* Fix docstring for CircuitDrawerMatplotlib

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Ibm backend v2 (solves ProjectQ-Framework#318 and ProjectQ-Framework#347) (ProjectQ-Framework#349)

* reduced Ry decomposition : modification of restrictedgateset setup to include compiler chooser, extension of available decompositions, new setup based on restrictedgateset but adapted for trapped ion configurations

* Addition of test file for the rz2rx decomposition

Addition of test file for the rz2rx decomposition and edit to comments in the rz2rx file

* Revert "Addition of test file for the rz2rx decomposition"

This reverts commit 5aab56b.

* Create rz2rx_test file

Addition of test file for the rz2rx decomposition

* Update rz2rx.py

Update to comments

* Update rz2rx_test.py

Update to comments

* Minor update: remove accidental file

* Minor update rz2rx.py

Corrected an angle.

* Minor update rz2rx_test.py

Edited comments.

* Create h2rx_test.py

Updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* Improvement of the decomposition chooser; Note that basic restricted gate
set will fail decomposing into Rxx because of the default chooser

* Updates to h2rx and cnot2rxx

* Create cnot2rxx_test.py

Testing file for cnot2rxx decomposition. Includes updated method for test_decomposition which tests that decomposition produces identical wave-state up to a global phase.

* basic rotation gates at an angle of 0 or 2pi are removed by the optimizer.
basic rotation gates ignore now the global phase and are defined over 0:2pi

* Update and create trapped_ion_decomposer_test.py

* Minor update

Documentation and comments.

* Update on comments regarding Identity gates

* Changes 1/2 : command can be printed with unicode symbols only via new
to_String method; syntax correction;

* Work in progress, is commutable

* Update to decomposition test files

rz2rx_test now tests each decomposition defined in rz2rx.all_defined_decomposition_rules
Similar for cnot2rxx_test and h2rx_test

* Revert "Work in progress, is commutable"

This reverts commit 27f820c.

* ibmq fix: projectq uses new ibmq API (no doc available, just look at qiskit). Connection fixed for 5qb devices, the 15qb melbourne device and the
online simulator
coupling map obtained from ibm server instead of being manually written
one setup can be used for the 3 different backend

* minor fixes

* update on the ibm example

* minor fixes; revert rotation gates to [0;4pi)

* fix comments

* fix mapper choice for simulator. added comments

* minor fixes with results, mapper and testing files. Improvement of
get_probabilities

* Revert "Merge branch 'develop' into ibm_V2"

This reverts commit cd0452a, reversing
changes made to 03daf79.

* minor fixes

* bug fix in client test file

* fixing bug and python2.7 compatibility for testing files

* fix errors

* major fix on testing files

* minor fix on comments and python 2.7 compatibility

* fix 'super()' call for python 2.7

* additional tests

* python2.7 fix

* increase coverage, fix a print statement

* Some minor stylistic adjustments

* Reindent files and fix some linting warnings/errors

* Improve test coverage

* Improve code readability

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Automatically generate documentation ReST files (ProjectQ-Framework#339)

* Automate generation of documentation ReST files

* Fix error in conf.py

* Adjust .gitignore

* Update setup.py (ProjectQ-Framework#337)

* Rewrite setup.py to fix some issues on Mac OSX and some code cleanup

- On Mac OSX with Homebrew, properly find the path to the OpenMP
  library if compiling with clang from Homebrew
- Code cleanup and some reformating

* Remove use of deprecated setuptools.Feature

Now try to compile the C++ simulator and if it fails, simply install
a pure Python package with some warning messages for the user.

* Update documentation to reflect the latest change to setup.py

* Fix error with deleted method of BuildExt

* Remove global COPYING file and move text to setup.py file itself

* Fix compilation issues on MacOS X

* Update .gitignore

* Fix setup.py for Python2 and MacPorts (Mac OS)

* Fix setup.py on Windows

* Some more fixes

* Attempt to fix failing installation on Travis CI

* Fix installation under Linux

* Undo changes in .travis.yml

* Update setup related tutorials

* Fix a few remaining typos.

* ProjectQ v0.5.0 (ProjectQ-Framework#356)

* Bumped version number to 0.5.0

* Remove unneeded test

* Fix error in examples/ibm.py

* Add documentation for **kwargs for CircuitDrawerMatplotlib

* Update setup.py license header

Co-authored-by: Damian Steiger <damiansteiger@users.noreply.github.com>

* Fix generated documentation (ProjectQ-Framework#360)

* Fix some issues with builtin modules and fix some warnings

* Move generated documentation files into dedicated folder

Co-authored-by: Damien Nguyen <damien1@huawei.com>

* Fix bugs with matplotlib drawer (ProjectQ-Framework#361)

* Accept keywords arguments for Matplotlib drawing

* fix circ drawer when depth == 1

Co-authored-by: Damien Nguyen <damien1@huawei.com>

Co-authored-by: Damian Steiger <damiansteiger@users.noreply.github.com>
Co-authored-by: Mathias Soeken <mathias.soeken@gmail.com>
Co-authored-by: Christian Gogolin <git@cgogolin.de>
Co-authored-by: Thomas Haener <thomashaener@users.noreply.github.com>
Co-authored-by: Damian S. Steiger <dsteiger@phys.ethz.ch>
Co-authored-by: Fernando <fernandodelaiglesia@users.noreply.github.com>
Co-authored-by: David Wierichs <davidwierichs@gmail.com>
Co-authored-by: Melven Roehrig-Zoellner <Melven.Roehrig-Zoellner@DLR.de>
Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>
Co-authored-by: alexandrupaler <alexandrupaler@gmail.com>
Co-authored-by: David Bretaud <40793394+dbretaud@users.noreply.github.com>
Co-authored-by: Cheng Li <lichengchris@gmail.com>
Co-authored-by: Nguyen Damien <damien1@huawei.com>
Co-authored-by: Ari Jordan <56979766+AriJordan@users.noreply.github.com>

* Passing unit tests

Co-authored-by: Damian Steiger <damiansteiger@users.noreply.github.com>
Co-authored-by: Mathias Soeken <mathias.soeken@gmail.com>
Co-authored-by: Christian Gogolin <git@cgogolin.de>
Co-authored-by: Thomas Haener <thomashaener@users.noreply.github.com>
Co-authored-by: Damian S. Steiger <dsteiger@phys.ethz.ch>
Co-authored-by: Fernando <fernandodelaiglesia@users.noreply.github.com>
Co-authored-by: David Wierichs <davidwierichs@gmail.com>
Co-authored-by: Melven Roehrig-Zoellner <Melven.Roehrig-Zoellner@DLR.de>
Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>
Co-authored-by: alexandrupaler <alexandrupaler@gmail.com>
Co-authored-by: David Bretaud <40793394+dbretaud@users.noreply.github.com>
Co-authored-by: Cheng Li <lichengchris@gmail.com>
Co-authored-by: Nguyen Damien <damien1@huawei.com>
Co-authored-by: Ari Jordan <56979766+AriJordan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants