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

Updated examples to instantiate gates instead of singletons AMAZON-QX-92 #38

Merged
merged 1 commit into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/braket/circuits/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def register_subroutine(cls, func: SubroutineCallable) -> None:
>>> def h_on_all(target):
... circ = Circuit()
... for qubit in target:
... circ += Instruction(Gate.H, qubit)
... circ += Instruction(Gate.H(), qubit)
... return circ
...
>>> Circuit.register_subroutine(h_on_all)
Expand Down Expand Up @@ -81,7 +81,7 @@ def __init__(self, addable: AddableTypes = None, *args, **kwargs):
TypeError: If `addable` is an unsupported type.

Examples:
>>> circ = Circuit([Instruction(Gate.H, 4), Instruction(Gate.CNot, [4, 5])])
>>> circ = Circuit([Instruction(Gate.H(), 4), Instruction(Gate.CNot(), [4, 5])])
>>> circ = Circuit().h(0).cnot(0, 1)

>>> @circuit.subroutine(register=True)
Expand Down Expand Up @@ -146,22 +146,22 @@ def add_instruction(
TypeError: If both `target_mapping` and `target` are supplied.

Examples:
>>> instr = Instruction(Gate.CNot, [0, 1])
>>> instr = Instruction(Gate.CNot(), [0, 1])
>>> circ = Circuit().add_instruction(instr)
>>> print(circ.instructions[0])
Instruction('operator': 'CNOT', 'target': QubitSet(Qubit(0), Qubit(1)))

>>> instr = Instruction(Gate.CNot, [0, 1])
>>> instr = Instruction(Gate.CNot(), [0, 1])
>>> circ = Circuit().add_instruction(instr, target_mapping={0: 10, 1: 11})
>>> print(circ.instructions[0])
Instruction('operator': 'CNOT', 'target': QubitSet(Qubit(10), Qubit(11)))

>>> instr = Instruction(Gate.CNot, [0, 1])
>>> instr = Instruction(Gate.CNot(), [0, 1])
>>> circ = Circuit().add_instruction(instr, target=[10, 11])
>>> print(circ.instructions[0])
Instruction('operator': 'CNOT', 'target': QubitSet(Qubit(10), Qubit(11)))

>>> instr = Instruction(Gate.H, 0)
>>> instr = Instruction(Gate.H(), 0)
>>> circ = Circuit().add_instruction(instr, target=[10, 11])
>>> print(circ.instructions[0])
Instruction('operator': 'H', 'target': QubitSet(Qubit(10),))
Expand Down Expand Up @@ -280,7 +280,7 @@ def add(self, addable: AddableTypes, *args, **kwargs) -> "Circuit":
`add_instruction()`

Examples:
>>> circ = Circuit().add([Instruction(Gate.H, 4), Instruction(Gate.CNot, [4, 5])])
>>> circ = Circuit().add([Instruction(Gate.H(), 4), Instruction(Gate.CNot(), [4, 5])])

>>> circ = Circuit().h(4).cnot([4, 5])

Expand Down
4 changes: 2 additions & 2 deletions src/braket/circuits/moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class Moments(Mapping[MomentsKey, Instruction]):

Examples:
>>> moments = Moments()
>>> moments.add([Instruction(Gate.H, 0), Instruction(Gate.CNot, [0, 1])])
>>> moments.add([Instruction(Gate.H, 0), Instruction(Gate.H, 1)])
>>> moments.add([Instruction(Gate.H(), 0), Instruction(Gate.CNot(), [0, 1])])
>>> moments.add([Instruction(Gate.H(), 0), Instruction(Gate.H(), 1)])
>>> for i, item in enumerate(moments.items()):
... print(f"Item {i}")
... print(f"\\tKey: {item[0]}")
Expand Down