rigetti / grove

Quantum algorithms built using pyQuil.

Home Page:http://rigetti.com/forest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VQE documentation is out of date with code

jmbr opened this issue · comments

When running the code snippets in grove/docs/vqe.rst the line

result = vqe_inst.vqe_run(small_ansatz, hamiltonian, initial_angle, samples=10000, qvm=noisy_qvm)

Raises the following exception:
TypeError: vqe_run() got an unexpected keyword argument 'qvm'

Similarly, the line result = vqe_inst.vqe_run(small_ansatz, hamiltonian, initial_angle, samples=10000, qvm=qvm) yields the error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/test_vqe.py in <module>
     17 vqe_inst = VQE(minimizer=minimize,
     18                minimizer_kwargs={'method': 'nelder-mead', 'options': {'disp': True}})
---> 19 result = vqe_inst.vqe_run(small_ansatz, hamiltonian, initial_angle)

~/rigetti/grove/grove/pyvqe/vqe.py in vqe_run(self, variational_state_evolve, hamiltonian, initial_params, gate_noise, measurement_noise, jacobian, qc, disp, samples, return_all)
    133             qc = QuantumComputer(name=f"{len(qubits)}q-noisy-qvm",
    134                                  qam=QVM(gate_noise=gate_noise,
--> 135                                          measurement_noise=measurement_noise))
    136         else:
    137             self.qc = qc

~/rigetti/pyquil/pyquil/api/_error_reporting.py in wrapper(*args, **kwargs)
    236             global_error_context.log[key] = pre_entry
    237
--> 238         val = func(*args, **kwargs)
    239
    240         # poke the return value of that call in

TypeError: __init__() missing 1 required positional argument: 'connection'```

The correct implementation of the function call is
result = vqe_inst.vqe_run(small_ansatz, hamiltonian, initial_angle, samples = 1000, qc=noisy_qvm)

I believe the function definition for vqe_run in class VQE was changed at a later date and the documentation wasn't updated to match the changes.