Skip to content

Commit

Permalink
Merge branch 'main' into fix-link
Browse files Browse the repository at this point in the history
  • Loading branch information
kt474 authored Sep 21, 2023
2 parents efcabe0 + 25e0b2b commit 4b27bbb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion qiskit_ibm_runtime/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(
max_time: (EXPERIMENTAL setting, can break between releases without warning)
Maximum amount of time, a runtime session can be open before being
forcibly closed. Can be specified as seconds (int) or a string like "2h 30m 40s".
This value must be in between 300 seconds and the
This value must be less than the
`system imposed maximum
<https://qiskit.org/documentation/partners/qiskit_ibm_runtime/faqs/max_execution_time.html>`_.
Expand Down
39 changes: 26 additions & 13 deletions test/unit/test_ibm_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,12 @@ def test_default_error_levels(self):
simulator={"noise_model": "foo"},
)
inst = cls(session=session, options=options)
inst.run(self.qx, observables=self.obs)

if isinstance(inst, Estimator):
inst.run(self.qx, observables=self.obs)
else:
inst.run(self.qx)

if sys.version_info >= (3, 8):
inputs = session.run.call_args.kwargs["inputs"]
else:
Expand Down Expand Up @@ -730,11 +735,12 @@ def test_raise_faulty_qubits(self):
estimator = Estimator(session=session)

with self.assertRaises(ValueError) as err:
sampler.run(transpiled, skip_transpilation=True)
estimator.run(transpiled, observable, skip_transpilation=True)
self.assertIn(f"faulty qubit {faulty_qubit}", str(err.exception))

transpiled.measure_all()
with self.assertRaises(ValueError) as err:
estimator.run(transpiled, observable, skip_transpilation=True)
sampler.run(transpiled, skip_transpilation=True)
self.assertIn(f"faulty qubit {faulty_qubit}", str(err.exception))

def test_raise_faulty_qubits_many(self):
Expand All @@ -759,11 +765,14 @@ def test_raise_faulty_qubits_many(self):
estimator = Estimator(session=session)

with self.assertRaises(ValueError) as err:
sampler.run(transpiled, skip_transpilation=True)
estimator.run(transpiled, [observable, observable], skip_transpilation=True)
self.assertIn(f"faulty qubit {faulty_qubit}", str(err.exception))

for circ in transpiled:
circ.measure_all()

with self.assertRaises(ValueError) as err:
estimator.run(transpiled, [observable, observable], skip_transpilation=True)
sampler.run(transpiled, skip_transpilation=True)
self.assertIn(f"faulty qubit {faulty_qubit}", str(err.exception))

def test_raise_faulty_edge(self):
Expand All @@ -785,12 +794,13 @@ def test_raise_faulty_edge(self):
estimator = Estimator(session=session)

with self.assertRaises(ValueError) as err:
sampler.run(transpiled, skip_transpilation=True)
estimator.run(transpiled, observable, skip_transpilation=True)
self.assertIn("cx", str(err.exception))
self.assertIn(f"faulty edge {tuple(edge_qubits)}", str(err.exception))

transpiled.measure_all()
with self.assertRaises(ValueError) as err:
estimator.run(transpiled, observable, skip_transpilation=True)
sampler.run(transpiled, skip_transpilation=True)
self.assertIn("cx", str(err.exception))
self.assertIn(f"faulty edge {tuple(edge_qubits)}", str(err.exception))

Expand All @@ -813,11 +823,12 @@ def test_faulty_qubit_not_used(self):
estimator = Estimator(session=session)

with patch.object(Session, "run") as mock_run:
sampler.run(transpiled, skip_transpilation=True)
estimator.run(transpiled, observable, skip_transpilation=True)
mock_run.assert_called_once()

transpiled.measure_active()
with patch.object(Session, "run") as mock_run:
estimator.run(transpiled, observable, skip_transpilation=True)
sampler.run(transpiled, skip_transpilation=True)
mock_run.assert_called_once()

def test_faulty_edge_not_used(self):
Expand All @@ -841,11 +852,12 @@ def test_faulty_edge_not_used(self):
estimator = Estimator(session=session)

with patch.object(Session, "run") as mock_run:
sampler.run(transpiled, skip_transpilation=True)
estimator.run(transpiled, observable, skip_transpilation=True)
mock_run.assert_called_once()

transpiled.measure_all()
with patch.object(Session, "run") as mock_run:
estimator.run(transpiled, observable, skip_transpilation=True)
sampler.run(transpiled, skip_transpilation=True)
mock_run.assert_called_once()

def test_no_raise_skip_transpilation(self):
Expand All @@ -870,11 +882,12 @@ def test_no_raise_skip_transpilation(self):
estimator = Estimator(session=session)

with patch.object(Session, "run") as mock_run:
sampler.run(transpiled)
estimator.run(transpiled, observable)
mock_run.assert_called_once()

transpiled.measure_all()
with patch.object(Session, "run") as mock_run:
estimator.run(transpiled, observable)
sampler.run(transpiled)
mock_run.assert_called_once()

def _update_dict(self, dict1, dict2):
Expand Down

0 comments on commit 4b27bbb

Please sign in to comment.