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

Adding state shape preservation to Solver.solve #99

Merged
merged 3 commits into from
May 4, 2022

Conversation

DanPuzzuoli
Copy link
Collaborator

Summary

Closes #96
Resolves the issue raised in discussion #95

Solver.solve respects input state type in the sense that if y0 is a quantum info type, then the returned solution is wrapped in the same class. However, as pointed out in discussion #95, the dimension data of y0 was not preserved when wrapping the solutions. This PR ensures updates Solver.solve to fix this.

Details and comments

The state type handling in Solver.solve is handled by initial_state_converter and final_state_converter. This PR updates initial_state_converter to also return a wrapper function to call to wrap the final states. This wrapper function is setup to include any additional kwargs needed beyond the array at construction - in this case dimension data. The function final_state_converter is removed as it is now redundant.

A test is also added to verify correct behaviour for various input types.

@DanPuzzuoli DanPuzzuoli requested a review from brosand April 26, 2022 18:13
@DanPuzzuoli DanPuzzuoli added Changelog: Bugfix Include in the "Fixed" section of the changelog Changelog: API Change Include in the "Changed" section of the changelog and removed Changelog: Bugfix Include in the "Fixed" section of the changelog labels Apr 26, 2022
Copy link
Contributor

@brosand brosand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple suggestions about making things a bit more exhaustive.

@DanPuzzuoli DanPuzzuoli merged commit 7f6ddaa into qiskit-community:main May 4, 2022
@DanPuzzuoli DanPuzzuoli deleted the state_shape branch May 4, 2022 19:49
donsano33 pushed a commit to donsano33/qiskit-dynamics that referenced this pull request Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: API Change Include in the "Changed" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add state meta data handling to Solver.solve
3 participants