amazon-braket-sdk-python icon indicating copy to clipboard operation
amazon-braket-sdk-python copied to clipboard

[SMALL] Support adding a single instruction to moments

Open christianbmadsen opened this issue 4 years ago • 2 comments

moments.add() and circuit.add() are slightly inconsistent. circuits accept both Instruction and Iterable[Instruction] while moments take a strict Iterable. This is confusing for the user:

circ.moments.add(Instruction(gate, target))  # doesnt work
circ.moments.add([Instruction(gate, target)])  # works

while both work for circuit classes:

circ.add(Instruction(gate, target)) # works
circ.add([Instruction(gate, target)]) # works

In the src code:

def add(self, instructions: Iterable[Instruction], noise_index: int = 0) -> None: # [moments](https://github.com/aws/amazon-braket-sdk-python/blob/main/src/braket/circuits/moments.py#L162)
def add(self, addable: AddableTypes, *args, **kwargs) -> Circuit: # [circuits](https://github.com/aws/amazon-braket-sdk-python/blob/main/src/braket/circuits/circuit.py#L777)

Objective: Update the Moments.add() method to accept Union[Instruction, Iterable[Instruction]]

Note: We expect a small task to take hours or a few days to complete dependent on your level of familiarity with the Braket SDK.

christianbmadsen avatar Aug 25 '21 18:08 christianbmadsen

Hi, I would like to work on this issue,🙂

himanshu007-creator avatar Aug 25 '21 18:08 himanshu007-creator

Hi, I would like to work on this issue,🙂

@himanshu007-creator touching base. Have you started looking at this issue? If you're stuck on how to proceed let us know.

christianbmadsen avatar Sep 15 '21 16:09 christianbmadsen