Skip to content

Deprecate TwoQubitGate and ThreeQubitGate #2164

@kevinsung

Description

@kevinsung

What is the use of gate_features.TwoQubitGate (and ThreeQubitGate, for that matter)? It doesn't define any method other than _num_qubits_.

The reason I think its existence could potentially be bad comes up when people want to count the number of two-qubit gates in their circuit. They might think to do

circuit.findall_operations_with_gate_type(cirq.TwoQubitGate)

but for this to work properly, every two-qubit gate in their circuit must be of a type explicitly declared to be a TwoQubitGate. I myself am wary of doing this and find myself always using the more sure-fire

circuit.findall_operations(lambda op: isinstance(op, cirq.GateOperation) and len(op.qubits) == 2)

instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/gatescomplexity/mediumintroduces/modifies 3-5 concepts, takes max up to a month for an advanced contributorkind/deprecationskill-level/advancedOne or more of the areas need a solid understanding.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions