Skip to content

Commit

Permalink
Fix bug for DynamicsBackend.solve with y0 an array (issue #350) (PR #351
Browse files Browse the repository at this point in the history
)
  • Loading branch information
donsano33 committed Mar 25, 2024
1 parent 5674e98 commit 5f40346
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion qiskit_dynamics/backend/dynamics_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def solve(
# use default y0 if not given as parameter
if y0 is None:
y0 = self.options.initial_state
if y0 == "ground_state":
if isinstance(y0, str) and y0 == "ground_state":
y0 = Statevector(self._dressed_states[:, 0])

solver_results = self.options.solver.solve(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fixes:
- |
:meth:`.DynamicsBackend.solve` method has been fixed to allow `y0` values of type `np.ndarray`.
2 changes: 2 additions & 0 deletions test/dynamics/backend/test_dynamics_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ def test_solve(self):
y0_and_expected_results.append(
(None, Statevector(QuantumCircuit(1)).evolve(expected_unitary))
)
# y0 is a np.array, we expect a np.array as a result
y0_and_expected_results.append((np.eye(static_ham.shape[0]), expected_unitary))
input_variety = [x_sched0, x_circ0]

# solve for all combinations of input types and initial states
Expand Down

0 comments on commit 5f40346

Please sign in to comment.