clean a minor fix _quantumprogram.py

and tests
This commit is contained in:
ismael faro 2017-05-16 05:33:53 -07:00
parent 7ace3f18d7
commit c510610e31
2 changed files with 11 additions and 50 deletions

View File

@ -52,7 +52,7 @@ class QuantumProgram(object):
""" Quantum Program Class
Class internal properties """
__online_devices = [ "IBMQX5qv2","ibmqx2", "ibmqx3", "ibmqx_qasm_simulator", "simulator"]
__online_devices = ["IBMQX5qv2", "ibmqx2", "ibmqx3", "ibmqx_qasm_simulator", "simulator"]
__local_devices = ["local_unitary_simulator", "local_qasm_simulator"]
__specs = {}
@ -521,15 +521,19 @@ class QuantumProgram(object):
else:
basicplotter.plot_qsphere(data, circuit_number)
def get_qasm_image(self,):
def get_qasm_image(self, circuit):
"""Get imagen circuit representation from API."""
pass
def get_data(self, results, i): #TODO: change the index for name
"""Get the dict of labels and counts from the output of get_job."""
return results['qasms'][i]['result']['data']['counts']
return results['compiled_circuits'][i]['result']['data']['counts']
#TODO: change the index for name and i think there is no point to get data above
# ALSO i think we need an assert if there is no results
def get_counts(self, i):
"""Get the dict of labels and counts from the output of get_job."""
return self.__qasm_compile['compiled_circuits'][i]['result']['data']['counts']
if isinstance(i, str):
pass
else:
return self.__qasm_compile['compiled_circuits'][i]['result']['data']['counts']

View File

@ -334,6 +334,7 @@ class TestQISKit(unittest.TestCase):
apiconnection = QP_program.set_api(
API_TOKEN, URL)
result = QP_program.execute(circuits, device, shots, max_credits=3)
# print(result)
self.assertEqual(result['status'], 'COMPLETED')
# QP_program.plotter()
@ -351,8 +352,8 @@ class TestQISKit(unittest.TestCase):
shots = 1024 # the number of shots in the experiment.
credits = 3
coupling_map = None
result = QP_program.execute(circuits, device, shots)
# print(result)
self.assertEqual(result['status'], 'COMPLETED')
def test_local_qasm_simulator_one_shot(self):
@ -369,6 +370,7 @@ class TestQISKit(unittest.TestCase):
credits = 3
coupling_map = None
result = QP_program.execute(circuits, device, shots)
# print(result)
self.assertEqual(result['compiled_circuits'][0]['result']['data']['classical_state'], 0)
def test_local_unitary_simulator(self):
@ -394,48 +396,3 @@ class TestQISKit(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
# TODO: Topology definition
# topology={
# hardware={},
# map={}
# }
# TODO:
# sim1 = myQP.set_scope(topology=topology)
# topology2={
# map={}
# }
# sim2 = myQP.set_scope( topology=topology2)
# sim1.compile.execute.plot()
# sim2.compile.execute.plot()
# sim1 = myQP.set_scope(hardware={}, map={}, topology={})
# myQP.compile()
# myQP.parse(versionQasm, qfiles)
# myQP.unroller()
# myQP.optimizer(standar)
# myQP.map(topology, operations)
# myQP.optimizer(cleaner)
# myQP.execute()
# myQP.execute()
# myQP.execute(debug = {})
# myQP.plot()
# hardware.status()
# hardware.command()
# use methods instead - or have method as well
# c1 = a + b + c
# c2 = a + bp + c
# chemistry1 = make_variational_state + do_measurement_1
# chemistry2 = make_variational_state + do_measurement_2
# p.add_circuit(c1)