> ## Documentation Index
> Fetch the complete documentation index at: https://tsim.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# encoder

> Transversal encoder utilities for QEC code experiments.

## class `ColorEncoder5`

```python theme={null}
ColorEncoder5()
```

Transversal encoder for the \[\[17,1,5]] 2D color code.

## class `SteaneEncoder`

```python theme={null}
SteaneEncoder()
```

Transversal encoder for the \[\[7,1,3]] Steane code.

## class `TransversalEncoder`

```python theme={null}
TransversalEncoder(n: int, encoding_qubit: int, encoding_program_text: str | None, stabilizer_generators: list[list[int]], observables: list[list[int]], transversal_flip: bool | None = None)
```

Base class for transversal quantum error correction encoders.

### `diagram`

```python theme={null}
diagram(kwargs = {})
```

Return a timeline-svg diagram of the encoded circuit.

### `encode_transversally`

```python theme={null}
encode_transversally(program_text: str) -> None
```

Encode a program transversally by replacing  physicalgates with transversal gates.

Transform a program on m qubits into a program on n \* m qubits (consisting of n code blocks).

**Parameters:**

* `program_text` (`str`) — The program to encode transversally.

### `encoding_flow_generators`

```python theme={null}
encoding_flow_generators()
```

Return the Pauli flow generators for the encoding circuit.

### `initialize`

```python theme={null}
initialize(program_text: str, encoding_program_text: str | None = None) -> None
```

Initialize state preparation and apply encoding circuit.

Apply the state preparation program for k qubits, then apply an encoding
circuit to encode the state into n qubits.

**Parameters:**

* `program_text` (`str`) — The state preparation program for k qubits. Generally, this should be a simple program that prepares each of the k qubits in a single-qubit state.
* `encoding_program_text` (`optional`) — An encoding circuit for a single logical qubit. This should encode a single logical qubit at input `self.encoding_qubit` into a state of n qubits. If not provided, the encoder will use a noiseless default encoding.

## `broadcast_targets`

```python theme={null}
broadcast_targets(groups: list[list[stim.GateTarget]], stride: int, offsets: list[int]) -> list[int]
```

Broadcast gate target groups with a stride and set of offsets.
