Skip to content

Commit

Permalink
Merge branch 'binary_encoder' of github.com:qiboteam/qibo into binary…
Browse files Browse the repository at this point in the history
…_encoder
  • Loading branch information
renatomello committed Dec 23, 2024
2 parents e0bb6ad + d229f25 commit 8a70898
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/qibo/models/encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ def binary_encoder(data, **kwargs):
gate_list = []
if len(anticontrols) > 0:
gate_list.append(gates.X(qubit) for qubit in anticontrols)
gate_list.append(gates.RY(targets[0], 0.0).controlled_by(*(controls + anticontrols)))
gate_list.append(
gates.RY(targets[0], 0.0).controlled_by(*(controls + anticontrols))
)
if len(anticontrols) > 0:
gate_list.append(gates.X(qubit) for qubit in anticontrols)
circuit.add(gate_list)
Expand All @@ -178,7 +180,6 @@ def binary_encoder(data, **kwargs):
return circuit



def unary_encoder(data, architecture: str = "tree", **kwargs):
"""Create circuit that performs the (deterministic) unary encoding of ``data``.
Expand Down
1 change: 1 addition & 0 deletions tests/test_models_encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def test_binary_encoder(backend, nqubits):
state = backend.execute_circuit(circuit).state()
backend.assert_allclose(state, target)


@pytest.mark.parametrize("kind", [None, list])
@pytest.mark.parametrize("architecture", ["tree", "diagonal"])
@pytest.mark.parametrize("nqubits", [8])
Expand Down

0 comments on commit 8a70898

Please sign in to comment.