(self, theta_batch)
| 31 | self.copies = copies |
| 32 | |
| 33 | def run(self, theta_batch): |
| 34 | job = qiskit.execute(self._circuit_, |
| 35 | self.backend, |
| 36 | shots=self.copies, |
| 37 | parameter_binds=[{self.theta: theta} for theta in theta_batch]) |
| 38 | result = job.result().get_counts(self._circuit_) |
| 39 | |
| 40 | counts = np.array(list(result.values())) |
| 41 | states = np.array(list(result.keys())).astype(float) |
| 42 | probs = counts / self.copies |
| 43 | expectation = np.array([np.sum(np.multiply(probs, states))]) |
| 44 | return expectation |
| 45 | |
| 46 | |
| 47 | class QuantumFunction(Function): |
no outgoing calls
no test coverage detected