Loading python/examples/pyscf_qubit_tapering.py +3 −3 Original line number Diff line number Diff line Loading @@ -10,9 +10,9 @@ print('\nTapered:\n', H_tapered) # Define a simple 1 qubit ansatz @qjit def ansatz(q : qreg, x : List[float]): Rx(q[0], x[0]) Ry(q[0], x[1]) def ansatz(q : qreg, phi : float, theta : float): Rx(q[0], phi) Ry(q[0], theta) # Create the problem model, provide the state # prep circuit, Hamiltonian and note variational parameters Loading python/qcor.py +12 −8 Original line number Diff line number Diff line Loading @@ -242,16 +242,20 @@ class qjit(object): argument variable should point to x[0], for example. """ if [str(x) for x in self.type_annotations.values()] == ['<class \'_pyqcor.qreg\'>', '<class \'float\'>']: ret_dict = {} for arg_name, _type in self.type_annotations.items(): if str(_type) == '<class \'_pyqcor.qreg\'>': ret_dict[arg_name] = q elif str(_type) == '<class \'float\'>': ret_dict[arg_name] = x[0] # Local vars used to figure out if we have # arg structures that look like (qreg, float...) type_annots_list = [str(self.type_annotations[x]) for x in self.arg_names] default_float_args = ['<class \'float\'>'] intersection = list(set(type_annots_list[1:]) & set(default_float_args) ) if intersection == default_float_args: # This handles all (qreg, float...) ret_dict = {self.arg_names[0]:q} for i, arg_name in enumerate(self.arg_names[1:]): ret_dict[arg_name] = x[i] if len(ret_dict) != len(self.type_annotations): print( 'Error, could not translate vector parameters x into arguments for quantum kernel.') 'Error, could not translate vector parameters x into arguments for quantum kernel. ', len(ret_dict), len(self.type_annotations)) exit(1) return ret_dict elif [str(x) for x in self.type_annotations.values()] == ['<class \'_pyqcor.qreg\'>', 'typing.List[float]']: Loading Loading
python/examples/pyscf_qubit_tapering.py +3 −3 Original line number Diff line number Diff line Loading @@ -10,9 +10,9 @@ print('\nTapered:\n', H_tapered) # Define a simple 1 qubit ansatz @qjit def ansatz(q : qreg, x : List[float]): Rx(q[0], x[0]) Ry(q[0], x[1]) def ansatz(q : qreg, phi : float, theta : float): Rx(q[0], phi) Ry(q[0], theta) # Create the problem model, provide the state # prep circuit, Hamiltonian and note variational parameters Loading
python/qcor.py +12 −8 Original line number Diff line number Diff line Loading @@ -242,16 +242,20 @@ class qjit(object): argument variable should point to x[0], for example. """ if [str(x) for x in self.type_annotations.values()] == ['<class \'_pyqcor.qreg\'>', '<class \'float\'>']: ret_dict = {} for arg_name, _type in self.type_annotations.items(): if str(_type) == '<class \'_pyqcor.qreg\'>': ret_dict[arg_name] = q elif str(_type) == '<class \'float\'>': ret_dict[arg_name] = x[0] # Local vars used to figure out if we have # arg structures that look like (qreg, float...) type_annots_list = [str(self.type_annotations[x]) for x in self.arg_names] default_float_args = ['<class \'float\'>'] intersection = list(set(type_annots_list[1:]) & set(default_float_args) ) if intersection == default_float_args: # This handles all (qreg, float...) ret_dict = {self.arg_names[0]:q} for i, arg_name in enumerate(self.arg_names[1:]): ret_dict[arg_name] = x[i] if len(ret_dict) != len(self.type_annotations): print( 'Error, could not translate vector parameters x into arguments for quantum kernel.') 'Error, could not translate vector parameters x into arguments for quantum kernel. ', len(ret_dict), len(self.type_annotations)) exit(1) return ret_dict elif [str(x) for x in self.type_annotations.values()] == ['<class \'_pyqcor.qreg\'>', 'typing.List[float]']: Loading