Skip to content

Remove deprecated two_qubit_matrix_to_diagonal_and_operations and two_qubit_matrix_to_operations #5102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cirq-core/cirq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,6 @@
transformer,
two_qubit_matrix_to_cz_operations,
two_qubit_matrix_to_diagonal_and_cz_operations,
two_qubit_matrix_to_diagonal_and_operations,
two_qubit_matrix_to_operations,
two_qubit_matrix_to_sqrt_iswap_operations,
two_qubit_gate_product_tabulation,
TwoQubitCompilationTargetGateset,
Expand Down
2 changes: 0 additions & 2 deletions cirq-core/cirq/optimizers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@
three_qubit_matrix_to_operations,
two_qubit_matrix_to_cz_operations,
two_qubit_matrix_to_diagonal_and_cz_operations,
two_qubit_matrix_to_diagonal_and_operations,
two_qubit_matrix_to_operations,
two_qubit_matrix_to_sqrt_iswap_operations,
)

Expand Down
2 changes: 0 additions & 2 deletions cirq-core/cirq/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
three_qubit_matrix_to_operations,
two_qubit_matrix_to_cz_operations,
two_qubit_matrix_to_diagonal_and_cz_operations,
two_qubit_matrix_to_diagonal_and_operations,
two_qubit_matrix_to_operations,
two_qubit_matrix_to_sqrt_iswap_operations,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
from cirq.transformers.analytical_decompositions.two_qubit_to_cz import (
two_qubit_matrix_to_cz_operations,
two_qubit_matrix_to_diagonal_and_cz_operations,
two_qubit_matrix_to_diagonal_and_operations,
two_qubit_matrix_to_operations,
)

from cirq.transformers.analytical_decompositions.two_qubit_to_fsim import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import numpy as np

from cirq import _compat
from cirq.linalg import predicates
from cirq.linalg.decompositions import num_cnots_required, extract_right_diag

Expand All @@ -32,33 +31,6 @@
import cirq


@_compat.deprecated(fix='Please use cirq.two_qubit_matrix_to_cz_operations', deadline='v0.15')
def two_qubit_matrix_to_operations(
q0: 'cirq.Qid',
q1: 'cirq.Qid',
mat: np.ndarray,
allow_partial_czs: bool,
atol: float = 1e-8,
clean_operations: bool = True,
) -> List[ops.Operation]:
"""Decomposes a two-qubit operation into Z/XY/CZ gates.

Args:
q0: The first qubit being operated on.
q1: The other qubit being operated on.
mat: Defines the operation to apply to the pair of qubits.
allow_partial_czs: Enables the use of Partial-CZ gates.
atol: A limit on the amount of absolute error introduced by the
construction.
clean_operations: Enables optimizing resulting operation list by
merging operations and ejecting phased Paulis and Z operations.

Returns:
A list of operations implementing the matrix.
"""
return two_qubit_matrix_to_cz_operations(q0, q1, mat, allow_partial_czs, atol, clean_operations)


def two_qubit_matrix_to_cz_operations(
q0: 'cirq.Qid',
q1: 'cirq.Qid',
Expand Down Expand Up @@ -89,40 +61,6 @@ def two_qubit_matrix_to_cz_operations(
return operations


@_compat.deprecated(
fix='Please use cirq.two_qubit_matrix_to_diagonal_and_cz_operations', deadline='v0.15'
)
def two_qubit_matrix_to_diagonal_and_operations(
q0: 'cirq.Qid',
q1: 'cirq.Qid',
mat: np.ndarray,
allow_partial_czs: bool = False,
atol: float = 1e-8,
clean_operations: bool = True,
) -> Tuple[np.ndarray, List['cirq.Operation']]:
"""Decomposes a 2-qubit unitary to a diagonal and the remaining operations.

For a 2-qubit unitary V, return ops, a list of operations and
D diagonal unitary, so that:
V = cirq.Circuit(ops) @ D

Args:
q0: The first qubit being operated on.
q1: The other qubit being operated on.
mat: the input unitary
allow_partial_czs: Enables the use of Partial-CZ gates.
atol: A limit on the amount of absolute error introduced by the
construction.
clean_operations: Enables optimizing resulting operation list by
merging operations and ejecting phased Paulis and Z operations.
Returns:
tuple(ops,D): operations `ops`, and the diagonal `D`
"""
return two_qubit_matrix_to_diagonal_and_cz_operations(
q0, q1, mat, allow_partial_czs, atol, clean_operations
)


def two_qubit_matrix_to_diagonal_and_cz_operations(
q0: 'cirq.Qid',
q1: 'cirq.Qid',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,6 @@ def assert_ops_implement_unitary(q0, q1, operations, intended_effect, atol=0.01)
assert cirq.allclose_up_to_global_phase(actual_effect, intended_effect, atol=atol)


def test_two_qubit_matrix_to_operations_deprecated():
q0 = cirq.NamedQubit('q0')
q1 = cirq.NamedQubit('q1')
effect = np.array(
[
[0, 0, 0, 1],
[0, 0, 1, 0],
[0, 1, 0, 0],
[1, 0, 0, 0j],
]
)

with cirq.testing.assert_deprecated('two_qubit_matrix_to_cz_operations', deadline='v0.15'):
_ = cirq.two_qubit_matrix_to_operations(q0, q1, effect, True)
with cirq.testing.assert_deprecated(
'two_qubit_matrix_to_diagonal_and_cz_operations', deadline='v0.15'
):
_ = cirq.two_qubit_matrix_to_diagonal_and_operations(q0, q1, effect, True)


@pytest.mark.parametrize(
'max_partial_cz_depth,max_full_cz_depth,effect',
[
Expand Down