Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug resulting from changing v5's default solver #190

Merged
merged 2 commits into from
Jan 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/qutip_qip/device/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,9 +1206,9 @@ def run_state(
else:
total_circuit_time = 0.0
if is_qutip5:
options = kwargs.get("options", qutip.SolverOptions())
if options["max_step"] == 0.0:
options["max_step"] = total_circuit_time / 10
options = kwargs.get("options", qutip.Options())
if options.get("max_step", 0.0) == 0.0:
options["max_step"] = total_circuit_time / 25
else:
options = kwargs.get("options", qutip.Options())
if options.max_step == 0.0:
Expand All @@ -1221,7 +1221,7 @@ def run_state(
)
elif solver == "mcsolve":
evo_result = mcsolve(
H=noisy_qobjevo, psi0=init_state, tlist=tlist, **kwargs
noisy_qobjevo, init_state, tlist=tlist, **kwargs
)

return evo_result
Expand Down
6 changes: 3 additions & 3 deletions src/qutip_qip/qiskit/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def convert_to_hex(count):
)[0]

exp_res_data = ExperimentResultData(
counts=counts, statevector=Statevector(data=np.array(statevector))
counts=counts, statevector=Statevector(data=statevector.full())
)

header = QobjExperimentHeader.from_dict(
Expand Down Expand Up @@ -366,9 +366,9 @@ def _parse_results(

exp_res_data = ExperimentResultData(
counts=counts,
statevector=Statevector(data=np.array(final_state))
statevector=Statevector(data=final_state.full())
if final_state.type == "ket"
else DensityMatrix(data=np.array(final_state)),
else DensityMatrix(data=final_state.full()),
)

header = QobjExperimentHeader.from_dict(
Expand Down
9 changes: 3 additions & 6 deletions tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
CircularSpinChain, SCQubits)

from packaging.version import parse as parse_version
if parse_version(qutip.__version__) < parse_version('5.dev'):
from qutip import Options as SolverOptions
else:
from qutip import SolverOptions
from qutip import Options

_tol = 3.e-2

Expand Down Expand Up @@ -126,7 +123,7 @@ def test_numerical_evolution(
init_state = _ket_expaned_dims(state, device.dims)
else:
init_state = state
options = SolverOptions(store_final_state=True, nsteps=50_000)
options = Options(store_final_state=True, nsteps=50_000)
result = device.run_state(init_state=init_state,
analytical=False,
options=options)
Expand Down Expand Up @@ -183,7 +180,7 @@ def test_numerical_circuit(circuit, device_class, kwargs, schedule_mode):
init_state = _ket_expaned_dims(state, device.dims)
else:
init_state = state
options = SolverOptions(store_final_state=True, nsteps=50_000)
options = Options(store_final_state=True, nsteps=50_000)
result = device.run_state(init_state=init_state,
analytical=False,
options=options)
Expand Down