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

Always return 1D vector from final_state_vector #5793

Merged
merged 5 commits into from
Jul 18, 2022

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Jul 17, 2022

Currently there is a special case for 0-qubit tensors, which causes the state vector to be returned as a scalar instead of a 1D vector of length 2**num_qubits == 1.

Also change the final_state_vector property to use _compat.cached_property.

Currently there is a special case for 0-qubit tensors, which causes the
state vector to be returned as a scalar instead of a 1D vector of length
2**num_qubits == 1.

Also change the `final_state_vector` property to use
`_compat.cached_property`.
@maffoo maffoo requested review from a team, vtomole and cduck as code owners July 17, 2022 16:52
@maffoo maffoo requested a review from mpharrigan July 17, 2022 16:52
@CirqBot CirqBot added the size: S 10< lines changed <50 label Jul 17, 2022
Copy link
Collaborator

@viathor viathor left a comment

Choose a reason for hiding this comment

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

LGTM

Optional: I'd add a unit test to ensure this "optimization" isn't added back in in future.

@maffoo maffoo added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 18, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 18, 2022
@CirqBot
Copy link
Collaborator

CirqBot commented Jul 18, 2022

Automerge cancelled: A required status check is not present.

Missing statuses: ['Pytest Windows (3.7)', 'Pytest Windows (3.8)', 'Pytest Windows (3.9)', 'Typescript lint check', 'Typescript tests', 'Typescript tests coverage']

@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jul 18, 2022
@maffoo maffoo added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 18, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 18, 2022
@CirqBot CirqBot merged commit 9f5e234 into master Jul 18, 2022
@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 18, 2022
@CirqBot CirqBot deleted the u/maffoo/final-state-vector branch July 18, 2022 04:36
@CirqBot CirqBot removed the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 18, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Currently there is a special case for 0-qubit tensors, which causes the state vector to be returned as a scalar instead of a 1D vector of length 2**num_qubits == 1.

Also change the `final_state_vector` property to use `_compat.cached_property`.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
Currently there is a special case for 0-qubit tensors, which causes the state vector to be returned as a scalar instead of a 1D vector of length 2**num_qubits == 1.

Also change the `final_state_vector` property to use `_compat.cached_property`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants