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

noncliff: improve error handling in apply!(sm, pcT) #374

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

Fe-r-oz
Copy link
Contributor

@Fe-r-oz Fe-r-oz commented Sep 30, 2024

This PR aims to improve the error handling for apply!(sm, pcT).

Before:

julia> p = embed(2, 1, pcT)
A unitary Pauli channel P = ∑ ϕᵢ Pᵢ with the following branches:
with ϕᵢ | Pᵢ
 0.853553+0.353553im | + __
 0.146447-0.353553im | + Z_

julia> sm = GeneralizedStabilizer(S"X")
A mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z
𝒮𝓉𝒶𝒷
+ X
with ϕᵢⱼ | Pᵢ | Pⱼ:
 1.0+0.0im | + _ | + _

julia> apply!(sm, p)
ERROR: BoundsError: attempt to access 2×1 view(::Matrix{UInt64}, :, 2:2) with eltype UInt64 at index [1:2, 2]
Stacktrace:
  [1] throw_boundserror(A::SubArray{UInt64, 2, Matrix{…}, Tuple{…}, true}, I::Tuple{Base.Slice{…}, Int64})
    @ Base ./abstractarray.jl:737
  [2] checkbounds
    @ ./abstractarray.jl:702 [inlined]
  [3] view
    @ ./subarray.jl:184 [inlined]
...
Some type information was truncated. Use `show(err)` to see complete types.

After:

julia> sm = GeneralizedStabilizer(random_stabilizer(2))
A mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z_
+ _Z
𝒮𝓉𝒶𝒷
+ YZ
+ ZX
with ϕᵢⱼ | Pᵢ | Pⱼ:
 1.0+0.0im | + __ | + __

julia> apply!(sm, pcT)
ERROR: DimensionMismatch: GeneralizedStabilizer has 2 qubits, but PauliChannel has 1. Use `embed` to create an appropriately padded PauliChannel.
Stacktrace:
 [1] apply!(state::GeneralizedStabilizer{…}, gate::PauliChannel{…}; prune_threshold::Float64)
...
  • The code is properly formatted and commented.
  • Substantial new functionality is documented within the docs.
  • All new functionality is tested.
  • All of the automated tests on github pass.

@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Oct 1, 2024

The PR is ready for review. Thank you!

src/nonclifford.jl Outdated Show resolved Hide resolved
@Krastanov Krastanov merged commit 78d4430 into QuantumSavory:nonclif Oct 25, 2024
8 of 12 checks passed
@Krastanov
Copy link
Member

thank you!

@Fe-r-oz Fe-r-oz deleted the enhance branch October 25, 2024 09:21
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