Skip to content

Commit

Permalink
ProjectQ v0.5.0 (#356)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Takishima and damiansteiger committed Mar 19, 2020
1 parent 63af3bf commit 89cb7fd
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 57 deletions.
5 changes: 3 additions & 2 deletions examples/ibm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
2 changes: 1 addition & 1 deletion projectq/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
23 changes: 23 additions & 0 deletions projectq/backends/_circuits/_drawer_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions projectq/backends/_circuits/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
53 changes: 0 additions & 53 deletions projectq/tests/_drawmpl_test.py

This file was deleted.

3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
# - Ants Aasma <ants.aasma@gmail.com>
# - Paul Johnston <paj@pajhome.org.uk>
# - Jonathan Ellis <jbellis@gmail.com>
# - Damien Nguyen <damien1@huawei.com> (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
Expand Down

0 comments on commit 89cb7fd

Please sign in to comment.