diff --git a/src/qibo/models/encodings.py b/src/qibo/models/encodings.py index 9b9fa620b..5b1bf71bd 100644 --- a/src/qibo/models/encodings.py +++ b/src/qibo/models/encodings.py @@ -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. @@ -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) @@ -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``. diff --git a/tests/test_models_encodings.py b/tests/test_models_encodings.py index 5ac965350..f781c0048 100644 --- a/tests/test_models_encodings.py +++ b/tests/test_models_encodings.py @@ -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])