Skip to content

Commit

Permalink
Add stimcirq tag conversions (#866)
Browse files Browse the repository at this point in the history
- Add `tag: str = ""` to `stim.Circuit.append`
- Stim tags now become string tags on cirq circuit operations
- A string tag on a cirq operation will turn into a stim tag by default
if there is exactly one such string tag
- Add optional `tag_func` argument to
`stimcirq.cirq_circuit_to_stim_circuit`

Some inspiration from #862
  • Loading branch information
Strilanc authored Dec 5, 2024
1 parent d70b206 commit 8767124
Show file tree
Hide file tree
Showing 18 changed files with 307 additions and 111 deletions.
5 changes: 5 additions & 0 deletions doc/python_api_reference_vDev.md
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,8 @@ def append(
name: str,
targets: Union[int, stim.GateTarget, Iterable[Union[int, stim.GateTarget]]],
arg: Union[float, Iterable[float]],
*,
tag: str = "",
) -> None:
pass
@overload
Expand All @@ -844,6 +846,8 @@ def append(
name: object,
targets: object = (),
arg: object = None,
*,
tag: str = '',
) -> None:
"""Appends an operation into the circuit.
Expand Down Expand Up @@ -894,6 +898,7 @@ def append(
compatibility reasons, `cirq.append_operation` (but not
`cirq.append`) will default to a single 0.0 argument for gates that
take exactly one argument.
tag: A customizable string attached to the instruction.
"""
```

Expand Down
7 changes: 7 additions & 0 deletions doc/stim.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ class Circuit:
name: str,
targets: Union[int, stim.GateTarget, Iterable[Union[int, stim.GateTarget]]],
arg: Union[float, Iterable[float]],
*,
tag: str = "",
) -> None:
pass
@overload
Expand All @@ -316,6 +318,8 @@ class Circuit:
name: object,
targets: object = (),
arg: object = None,
*,
tag: str = '',
) -> None:
"""Appends an operation into the circuit.
Expand Down Expand Up @@ -366,6 +370,7 @@ class Circuit:
compatibility reasons, `cirq.append_operation` (but not
`cirq.append`) will default to a single 0.0 argument for gates that
take exactly one argument.
tag: A customizable string attached to the instruction.
"""
def append_from_stim_program_text(
self,
Expand Down Expand Up @@ -398,6 +403,8 @@ class Circuit:
name: object,
targets: object = (),
arg: object = None,
*,
tag: str = '',
) -> None:
"""[DEPRECATED] use stim.Circuit.append instead
"""
Expand Down
Loading

0 comments on commit 8767124

Please sign in to comment.