-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding
embed
methods for AbstractStabilizer
and Tableau
- Loading branch information
Showing
3 changed files
with
188 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
@testitem "embed PauliOperator" begin | ||
@test embed(5,3,P"-Y") == P"-__Y__" | ||
@test embed(5,(3,5),P"-YZ") == P"-__Y_Z" | ||
@test embed(5,[3,5],P"-YZ") == P"-__Y_Z" | ||
@test_throws ArgumentError embed(5,[3,5],P"-YZX") | ||
@test_throws ArgumentError embed(5,3,P"-ZX") | ||
@testitem "embed methods" begin | ||
|
||
@testset "embed PauliOperator" begin | ||
@test embed(5,3,P"-Y") == P"-__Y__" | ||
@test embed(5,(3,5),P"-YZ") == P"-__Y_Z" | ||
@test embed(5,[3,5],P"-YZ") == P"-__Y_Z" | ||
@test_throws ArgumentError embed(5,[3,5],P"-YZX") | ||
@test_throws ArgumentError embed(5,3,P"-ZX") | ||
end | ||
|
||
@testset "embed Stabilizer" begin | ||
@test embed(5,3,S"-Y") == S"-__Y__" | ||
@test embed(5,(3,5),S"-YZ") == S"-__Y_Z" | ||
@test embed(5,[3,5],S"-YZ") == S"-__Y_Z" | ||
@test embed(5, 5, S"-Y Z") == S"-____Y ____Z" | ||
@test embed(5, (2,4), S"XX -YZ") == S"_X_X_ -_Y_Z_" | ||
@test_throws ArgumentError embed(5,[3,5],S"-YZX") | ||
@test_throws ArgumentError embed(5,3,S"-ZX") | ||
end | ||
|
||
@testset "embed Tableau" begin | ||
@test embed(5,3,T"-Y") == T"-__Y__" | ||
@test embed(5,(3,5),T"-YZ") == T"-__Y_Z" | ||
@test embed(5,[3,5],T"-YZ") == T"-__Y_Z" | ||
@test embed(5, 5, T"-Y Z") == T"-____Y ____Z" | ||
@test embed(5, (2,4), T"XX -YZ") == T"_X_X_ -_Y_Z_" | ||
@test_throws ArgumentError embed(5,[3,5],T"-YZX") | ||
@test_throws ArgumentError embed(5,3,T"-ZX") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,72 @@ | ||
@testitem "throws" begin | ||
using QuantumClifford: rank, mul_left!, mul_right! | ||
using InteractiveUtils: subtypes | ||
using QuantumClifford: rank, mul_left!, mul_right! | ||
using InteractiveUtils: subtypes | ||
|
||
@test_throws DimensionMismatch CliffordOperator(T"XXX ZZ_") | ||
@test_throws DimensionMismatch CliffordOperator(T"XXX ZZ_") | ||
|
||
@test_throws DimensionMismatch tCNOT*S"X" | ||
@test_throws DimensionMismatch tCNOT*S"X" | ||
|
||
#@test_throws DomainError bigram(random_stabilizer(50), clip=false) | ||
#@test_throws DomainError bigram(random_stabilizer(50), clip=false) | ||
|
||
@test_throws DomainError logdot(S"XX", S"XX ZZ") | ||
@test_throws DimensionMismatch logdot(S"X", S"XX ZZ") | ||
@test_throws DomainError logdot(S"XX", S"XX ZZ") | ||
@test_throws DimensionMismatch logdot(S"X", S"XX ZZ") | ||
|
||
@test_throws BadDataStructure rank(S"X") | ||
@test_throws BadDataStructure rank(Destabilizer(S"X")) | ||
@test_throws BadDataStructure rank(S"X") | ||
@test_throws BadDataStructure rank(Destabilizer(S"X")) | ||
|
||
@test_throws DimensionMismatch mul_left!(P"X", P"XX") | ||
@test_throws DimensionMismatch mul_right!(P"X", P"XX") | ||
@test_throws DimensionMismatch mul_left!(P"X", P"XX") | ||
@test_throws DimensionMismatch mul_right!(P"X", P"XX") | ||
|
||
@test_throws ArgumentError StabMixture(S"XX") | ||
@test_throws ArgumentError StabMixture(S"XX") | ||
|
||
@test_throws ArgumentError UnitaryPauliChannel([P"X"], [1,2]) | ||
@test_throws ArgumentError UnitaryPauliChannel([P"X",P"XX"], [1,2]) | ||
@test_throws ArgumentError UnitaryPauliChannel([P"X"], [1,2]) | ||
@test_throws ArgumentError UnitaryPauliChannel([P"X",P"XX"], [1,2]) | ||
|
||
@test_throws ArgumentError embed(10,2,P"XX") | ||
@test_throws ArgumentError embed(10,[2,3],P"X") | ||
@test_throws ArgumentError embed(10,2,P"XX") | ||
@test_throws ArgumentError embed(10,[2,3],P"X") | ||
|
||
struct A <: QuantumClifford.AbstractOperation end | ||
@test_throws ArgumentError applybranches(S"X",A()) | ||
@test_throws ArgumentError embed(10,2,S"XX") | ||
@test_throws ArgumentError embed(10,[2,3],S"X") | ||
|
||
@test_throws BadDataStructure project!(Destabilizer(S"XX"), P"ZZ") | ||
@test_throws ArgumentError embed(10,2,T"XX") | ||
@test_throws ArgumentError embed(10,[2,3],T"X") | ||
|
||
@test_throws DimensionMismatch reset_qubits!(ghz(4), ghz(3), [1,2]) | ||
@test_throws DimensionMismatch reset_qubits!(ghz(3), ghz(4), [1,2,3,4]) | ||
@test_throws DimensionMismatch reset_qubits!(MixedStabilizer(ghz(4)), MixedStabilizer(ghz(3)), [1,2]) | ||
@test_throws DimensionMismatch reset_qubits!(MixedStabilizer(ghz(3)), MixedStabilizer(ghz(4)), [1,2,3,4]) | ||
@test_throws DimensionMismatch reset_qubits!(MixedDestabilizer(ghz(4)), MixedDestabilizer(ghz(3)), [1,2]) | ||
@test_throws DimensionMismatch reset_qubits!(MixedDestabilizer(ghz(3)), MixedDestabilizer(ghz(4)), [1,2,3,4]) | ||
struct A <: QuantumClifford.AbstractOperation end | ||
@test_throws ArgumentError applybranches(S"X",A()) | ||
|
||
#TODO broken in other ways @test_throws DomainError MixedDestabilizer(Destabilizer(S"XX")) | ||
@test_throws BadDataStructure project!(Destabilizer(S"XX"), P"ZZ") | ||
|
||
@test_throws DomainError 2*P"X" | ||
@test_throws DimensionMismatch reset_qubits!(ghz(4), ghz(3), [1,2]) | ||
@test_throws DimensionMismatch reset_qubits!(ghz(3), ghz(4), [1,2,3,4]) | ||
@test_throws DimensionMismatch reset_qubits!(MixedStabilizer(ghz(4)), MixedStabilizer(ghz(3)), [1,2]) | ||
@test_throws DimensionMismatch reset_qubits!(MixedStabilizer(ghz(3)), MixedStabilizer(ghz(4)), [1,2,3,4]) | ||
@test_throws DimensionMismatch reset_qubits!(MixedDestabilizer(ghz(4)), MixedDestabilizer(ghz(3)), [1,2]) | ||
@test_throws DimensionMismatch reset_qubits!(MixedDestabilizer(ghz(3)), MixedDestabilizer(ghz(4)), [1,2,3,4]) | ||
|
||
@test_throws DimensionMismatch P"X" * S"XX" | ||
#TODO broken in other ways @test_throws DomainError MixedDestabilizer(Destabilizer(S"XX")) | ||
|
||
@test_throws ArgumentError one(typeof(T"X"), 1, basis=:U) | ||
@test_throws DomainError 2*P"X" | ||
|
||
for gt in subtypes(QuantumClifford.AbstractSingleQubitOperator) | ||
gt == SingleQubitOperator && continue | ||
@test_throws ArgumentError gt(0) | ||
@test_throws ArgumentError gt(-1) | ||
end | ||
@test_throws DimensionMismatch P"X" * S"XX" | ||
|
||
for gt in subtypes(QuantumClifford.AbstractTwoQubitOperator) | ||
@test_throws ArgumentError gt(0,1) | ||
@test_throws ArgumentError gt(-1,1) | ||
@test_throws ArgumentError gt(2,2) | ||
end | ||
@test_throws ArgumentError one(typeof(T"X"), 1, basis=:U) | ||
|
||
for m in [sMX,sMZ,sMY,sMRX,sMRZ,sMRY] | ||
@test_throws ArgumentError m(0) | ||
@test_throws ArgumentError m(-1) | ||
@test_throws ArgumentError m(0,1) | ||
@test_throws ArgumentError m(-1,0) | ||
end | ||
for gt in subtypes(QuantumClifford.AbstractSingleQubitOperator) | ||
gt == SingleQubitOperator && continue | ||
@test_throws ArgumentError gt(0) | ||
@test_throws ArgumentError gt(-1) | ||
end | ||
|
||
for gt in subtypes(QuantumClifford.AbstractTwoQubitOperator) | ||
@test_throws ArgumentError gt(0,1) | ||
@test_throws ArgumentError gt(-1,1) | ||
@test_throws ArgumentError gt(2,2) | ||
end | ||
|
||
for m in [sMX,sMZ,sMY,sMRX,sMRZ,sMRY] | ||
@test_throws ArgumentError m(0) | ||
@test_throws ArgumentError m(-1) | ||
@test_throws ArgumentError m(0,1) | ||
@test_throws ArgumentError m(-1,0) | ||
end | ||
end |