-
Notifications
You must be signed in to change notification settings - Fork 15
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
Some usability improvements for project_traceout!()
#35
Conversation
Codecov Report
@@ Coverage Diff @@
## master #35 +/- ##
==========================================
+ Coverage 65.15% 65.51% +0.36%
==========================================
Files 23 23
Lines 927 928 +1
==========================================
+ Hits 604 608 +4
+ Misses 323 320 -3
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -37,11 +37,13 @@ function observable(state::Union{<:Ket,<:Operator}, indices, operation) | |||
expect(op, state) | |||
end | |||
|
|||
function project_traceout!(state::Union{Ket,Operator},stateindex,psis::Vector{<:Ket}) | |||
function project_traceout!(state::Union{Ket,Operator},stateindex,psis::Union{Tuple,Vector{<:Ket}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use Base.AbstractVecOrTuple
here (which is almost the same union), to keep things consistent
@Abhishek-1Bhatt , could you investigate what I broke here? |
@@ -37,11 +37,13 @@ function observable(state::Union{<:Ket,<:Operator}, indices, operation) | |||
expect(op, state) | |||
end | |||
|
|||
function project_traceout!(state::Union{Ket,Operator},stateindex,psis::Vector{<:Ket}) | |||
function project_traceout!(state::Union{Ket,Operator},stateindex,psis::Base.AbstractVecOrTuple{Ket}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the problem is that the symbolic basis states like Z1
, X2
etc aren't direct subtypes of Ket
, but SpecialKet
here.
Should I just replace it with
function project_traceout!(state::Union{Ket,Operator},stateindex,psis::Base.AbstractVecOrTuple{<:Union{Ket, QuantumSymbolics.SpecialKet}})
Allows
project_traceout()
to accept Tuples of possible basis states. Also added a more descriptive error message when the state to be measured is not normalized.