JackHidary / quantumcomputingbook

Companion site for the textbook Quantum Computing: An Applied Approach
789 stars 215 forks source link

qnn.py update for most recent versions of Cirq (v0.11+) #41

Open qlero opened 2 years ago

qlero commented 2 years ago

Hello,

As discussed in issues, here is a pull request with a small update on chapter 9's qnn.py script. The following changes have been made:

  1. (add-on compared to opened issue) Removal of TwoQubitGate from the inheritance arguments of class ZXGate (lines 10-11) as it will be deprecated with cirq v0.14 onward. This is replaced with overriding the function _num_qubits_ in the body of the class such that:
    def _num_qubits_(self):
        return 2
  2. Addition of the recursive:bool argument to the override of the function _resolve_parameters_ (line 36) in the body of custom class ZXGate so as to work with cirq versions v0.11 and further.
  3. Replacement of wf = result.final_state with wf = result.final_state_vector (line 79) in the body of function readout_expectation.

Best regards,

Quentin