From fce5921a3c03f6dd6d84d9eb26677c74e30d8651 Mon Sep 17 00:00:00 2001 From: Damien Nguyen Date: Wed, 19 Feb 2020 11:25:48 +0100 Subject: [PATCH 1/5] Bumped version number to 0.5.0 --- projectq/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projectq/_version.py b/projectq/_version.py index 61a0a8d6a..6900d1135 100755 --- a/projectq/_version.py +++ b/projectq/_version.py @@ -13,4 +13,4 @@ # limitations under the License. """Define version number here and read it from setup.py automatically""" -__version__ = "0.4.2" +__version__ = "0.5.0" From cec7452e67db119f3918ffe2ab6d9ab99214f164 Mon Sep 17 00:00:00 2001 From: Damien Nguyen Date: Fri, 28 Feb 2020 17:43:11 +0100 Subject: [PATCH 2/5] Remove unneeded test --- projectq/tests/_drawmpl_test.py | 53 --------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 projectq/tests/_drawmpl_test.py diff --git a/projectq/tests/_drawmpl_test.py b/projectq/tests/_drawmpl_test.py deleted file mode 100644 index 3d78befa6..000000000 --- a/projectq/tests/_drawmpl_test.py +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 2017 ProjectQ-Framework (www.projectq.ch) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -''' - Tests for projectq.backends._circuits._drawer.py. - - To generate the baseline images - run the tests with '--mpl-generate-path=baseline' - - Then run the tests simply with '--mpl' -''' - -import pytest -from projectq import MainEngine -from projectq.ops import * -from projectq.backends import Simulator -from projectq.backends import CircuitDrawerMatplotlib -from projectq.cengines import DecompositionRuleSet, AutoReplacer -import projectq.setups.decompositions - -@pytest.mark.mpl_image_compare -def test_drawer_mpl(): - drawer = CircuitDrawerMatplotlib() - rule_set = DecompositionRuleSet(modules=[projectq.setups.decompositions]) - eng = MainEngine(backend=Simulator(), engine_list=[AutoReplacer(rule_set), - drawer]) - ctrl = eng.allocate_qureg(2) - qureg = eng.allocate_qureg(3) - - Swap | (qureg[0], qureg[2]) - C(Swap) | (qureg[0], qureg[1], qureg[2]) - - CNOT | (qureg[0], qureg[2]) - Rx(1.0) | qureg[0] - CNOT | (qureg[1], qureg[2]) - C(X, 2) | (ctrl[0], ctrl[1], qureg[2]) - QFT | qureg - All(Measure) | qureg - - eng.flush() - fig, ax = drawer.draw() - return fig \ No newline at end of file From f7f57a1553d00758e0f4425f35461210943f0c6a Mon Sep 17 00:00:00 2001 From: Damien Nguyen Date: Fri, 28 Feb 2020 14:21:36 +0100 Subject: [PATCH 3/5] Fix error in examples/ibm.py --- examples/ibm.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/ibm.py b/examples/ibm.py index 37ba4e0d7..11a81a832 100755 --- a/examples/ibm.py +++ b/examples/ibm.py @@ -49,8 +49,9 @@ def run_entangle(eng, num_qubits=3): if device is None: token = getpass.getpass(prompt='IBM device > ') # create main compiler engine for the IBM back-end - eng = MainEngine(IBMBackend(use_hardware=True, token=token num_runs=1024, + eng = MainEngine(IBMBackend(use_hardware=True, token=token, num_runs=1024, verbose=False, device=device), - engine_list=projectq.setups.ibm.get_engine_list(token=token, device=device)) + engine_list=projectq.setups.ibm.get_engine_list( + token=token, device=device)) # run the circuit and print the result print(run_entangle(eng)) From f5d43e9844f41293b0269b35563dfc77046c14b5 Mon Sep 17 00:00:00 2001 From: Damien Nguyen Date: Thu, 20 Feb 2020 09:33:05 +0100 Subject: [PATCH 4/5] Add documentation for **kwargs for CircuitDrawerMatplotlib --- .../backends/_circuits/_drawer_matplotlib.py | 23 +++++++++++++++++++ projectq/backends/_circuits/_plot.py | 21 +++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/projectq/backends/_circuits/_drawer_matplotlib.py b/projectq/backends/_circuits/_drawer_matplotlib.py index 23a07c767..3b16d914e 100644 --- a/projectq/backends/_circuits/_drawer_matplotlib.py +++ b/projectq/backends/_circuits/_drawer_matplotlib.py @@ -192,9 +192,32 @@ def draw(self, qubit_labels=None, drawing_order=None): drawing_order (dict): position of each qubit in the output graphic. Keys: qubit IDs, Values: position of qubit on the qubit line in the graphic. + **kwargs (dict): additional parameters are used to update + the default plot parameters Returns: A tuple containing the matplotlib figure and axes objects + + Note: + Additional keyword arguments can be passed to this + function in order to further customize the figure output + by matplotlib (default value in parentheses): + + - fontsize (14): Font size in pt + - column_spacing (.5): Vertical spacing between two + neighbouring gates (roughly in inches) + - control_radius (.015): Radius of the circle for controls + - labels_margin (1): Margin between labels and begin of + wire (roughly in inches) + - linewidth (1): Width of line + - not_radius (.03): Radius of the circle for X/NOT gates + - gate_offset (.05): Inner margins for gates with a text + representation + - mgate_width (.1): Width of the measurement gate + - swap_delta (.02): Half-size of the SWAP gate + - x_offset (.05): Absolute X-offset for drawing within the axes + - wire_height (1): Vertical spacing between two qubit + wires (roughly in inches) """ max_depth = max( len(self._qubit_lines[qubit_id]) for qubit_id in self._qubit_lines) diff --git a/projectq/backends/_circuits/_plot.py b/projectq/backends/_circuits/_plot.py index 009b00ab7..edc0a1f72 100644 --- a/projectq/backends/_circuits/_plot.py +++ b/projectq/backends/_circuits/_plot.py @@ -78,6 +78,27 @@ def to_draw(qubit_lines, qubit_labels=None, drawing_order=None, **kwargs): Note: Numbering of qubit wires starts at 0 at the bottom and increases vertically. + + Note: + Additional keyword arguments can be passed to this + function in order to further customize the figure output + by matplotlib (default value in parentheses): + + - fontsize (14): Font size in pt + - column_spacing (.5): Vertical spacing between two + neighbouring gates (roughly in inches) + - control_radius (.015): Radius of the circle for controls + - labels_margin (1): Margin between labels and begin of + wire (roughly in inches) + - linewidth (1): Width of line + - not_radius (.03): Radius of the circle for X/NOT gates + - gate_offset (.05): Inner margins for gates with a text + representation + - mgate_width (.1): Width of the measurement gate + - swap_delta (.02): Half-size of the SWAP gate + - x_offset (.05): Absolute X-offset for drawing within the axes + - wire_height (1): Vertical spacing between two qubit + wires (roughly in inches) """ if qubit_labels is None: qubit_labels = {qubit_id: r'$|0\rangle$' for qubit_id in qubit_lines} From 32513f1095907a064a1d39095c1fa17637766da2 Mon Sep 17 00:00:00 2001 From: Nguyen Damien Date: Thu, 19 Mar 2020 09:12:35 +0100 Subject: [PATCH 5/5] Update setup.py license header --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b1cb36321..5049a3a06 100755 --- a/setup.py +++ b/setup.py @@ -13,8 +13,9 @@ # - Ants Aasma # - Paul Johnston # - Jonathan Ellis +# - Damien Nguyen (ProjectQ) -# Copyright 2005-2019 SQLAlchemy authors and contributors (see above) +# Copyright 2005-2020 SQLAlchemy and ProjectQ authors and contributors (see above) # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to