Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 23, 2024
1 parent efecd8f commit d229f25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/qibo/models/encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def binary_encoder(data, **kwargs):
"""Create circuit that encodes ``data`` in all amplitudes of the computational basis.
Data has to be normalized with respect to the Hilbert-Schmidt norm.
Args:
data (ndarray or list): :math:`1`-dimensional array or length :math:`2^{n}`
to be loaded in the amplitudes of a :math:`n`-qubit quantum state.
Expand Down Expand Up @@ -165,7 +165,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 @@ -176,7 +178,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 d229f25

Please sign in to comment.