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

Some usability improvements for project_traceout!() #35

Merged
merged 5 commits into from
Aug 29, 2023

Conversation

ba2tro
Copy link
Member

@ba2tro ba2tro commented Aug 26, 2023

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.

@codecov
Copy link

codecov bot commented Aug 26, 2023

Codecov Report

Merging #35 (fc73f76) into master (29d87e4) will increase coverage by 0.36%.
The diff coverage is 100.00%.

@@            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     
Files Changed Coverage Δ
src/backends/quantumoptics/quantumoptics.jl 88.37% <100.00%> (+0.27%) ⬆️

... 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}})
Copy link
Member

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

@Krastanov Krastanov merged commit 09fe3aa into QuantumSavory:master Aug 29, 2023
@Krastanov
Copy link
Member

@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})
Copy link
Member Author

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}})

@ba2tro ba2tro deleted the functions branch September 18, 2023 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants