baddb11a55a68c29cdc319bc9dde6e0a24ad32fe,cirq/ionq/serializer.py,Serializer,serialize,#Serializer#Any#,55

Before Change


            ValueError: if the circuit has gates that are not supported or
                is otherwise invalid.
        
        if len(circuit) == 0:
            raise ValueError("Cannot serialize empty circuit.")
        all_qubits = circuit.all_qubits()
        if any(not isinstance(q, line_qubit.LineQubit) for q in all_qubits):
            raise ValueError(
                f"All qubits must be cirq.LineQubits but were {set(type(q) for q in all_qubits)}"
            )
        num_qubits = cast(line_qubit.LineQubit, max(all_qubits)).x + 1
        return {"qubits": num_qubits, "circuit": self._serialize_circuit(circuit, num_qubits)}

    def _serialize_circuit(self, circuit: "cirq.Circuit", num_qubits: int) -> list:
        return [self._serialize_op(op) for moment in circuit for op in moment]

After Change


        self._validate_circuit(circuit)
        num_qubits = self._validate_qubits(circuit.all_qubits())

        serialized_ops = self._serialize_circuit(circuit)

        // IonQ API does not support measurements, so we pass the measurement keys through
        // the metadata field.  Here we split these out of the serialized ops.
        body = {
            "qubits": num_qubits,
            "circuit": [op for op in serialized_ops if op["gate"] != "meas"],
        }
        metadata = self._serialize_measurements(op for op in serialized_ops if op["gate"] == "meas")
        return SerializedProgram(body=body, metadata=metadata)

    def _validate_circuit(self, circuit: "cirq.Circuit"):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 11

Instances


Project Name: quantumlib/Cirq
Commit Name: baddb11a55a68c29cdc319bc9dde6e0a24ad32fe
Time: 2020-12-08
Author: dabacon@gmail.com
File Name: cirq/ionq/serializer.py
Class Name: Serializer
Method Name: serialize


Project Name: IndicoDataSolutions/finetune
Commit Name: 880e57c9796c5f4ed79195bdd38bc4b0d3abf25f
Time: 2018-10-01
Author: benlt@hotmail.co.uk
File Name: finetune/saver.py
Class Name: Saver
Method Name: save


Project Name: stellargraph/stellargraph
Commit Name: b52e083827ce7aefda75c4370db0ad6942e27dae
Time: 2018-08-12
Author: docherty@gmail.com
File Name: stellar/mapper/node_mappers.py
Class Name: HinSAGENodeMapper
Method Name: __getitem__