0
$\begingroup$

I am working on a Cirq notebook and the quantum circuit is created in this way:

import cirq
import numpy as np

from cirq import GridQubit, Circuit

from cirq import Simulator
simulator = Simulator()

q = GridQubit(0,0)
circuit = Circuit.from_ops(
    cirq.measure(q, key='m')
)

and I receive an error:

AttributeError: type object 'Circuit' has no attribute 'from_ops'

What should I do to fix it?

$\endgroup$

1 Answer 1

2
$\begingroup$

from_ops was deprecated a long time ago. You can just call cirq.Circuit(*ops) like

import cirq
import numpy as np

from cirq import GridQubit, Circuit

from cirq import Simulator
simulator = Simulator()

q = GridQubit(0,0)
circuit = Circuit(
    cirq.measure(q, key='m')
)

instead.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.