diff --git a/src/QuantumClifford.jl b/src/QuantumClifford.jl index e7f083981..f1b3b6aa6 100644 --- a/src/QuantumClifford.jl +++ b/src/QuantumClifford.jl @@ -993,10 +993,14 @@ end # Conversion and promotion ############################## -Base.promote_rule(::Type{<:Stabilizer{T}} , ::Type{<:Destabilizer{T}} ) where {T<:Tableau} = MixedDestabilizer{T} -Base.promote_rule(::Type{<:MixedDestabilizer{T}}, ::Type{<:Stabilizer{T}} ) where {T<:Tableau} = MixedDestabilizer{T} - -Base.convert(::Type{<:MixedDestabilizer{T}}, x::Union{Destabilizer{T}, Stabilizer{T}}) where {T <: Tableau} = MixedDestabilizer(x) +# Destabilizer, MixedDestabilizer -> MixedDestabilizer +Base.promote_rule(::Type{<:Destabilizer{T}} , ::Type{<:MixedDestabilizer{T}}) where {T<:Tableau} = MixedDestabilizer{T} +# MixedStabilizer, MixedDestabilizer -> MixedDestabilizer +Base.promote_rule(::Type{<:MixedStabilizer{T}}, ::Type{<:MixedDestabilizer{T}}) where {T<:Tableau} = MixedDestabilizer{T} +# Stabilizer, T<:Union{MixedStabilizer, Destabilizer, MixedDestabilizer} -> T +Base.promote_rule(::Type{<:Stabilizer{T}} , ::Type{<:S} ) where {T<:Tableau, S<:Union{MixedStabilizer{T}, Destabilizer{T}, MixedDestabilizer{T}}} = S + +Base.convert(::Type{<:MixedDestabilizer{T}}, x::Union{Destabilizer{T}, MixedStabilizer{T}, Stabilizer{T}}) where {T <: Tableau} = MixedDestabilizer(x) ############################## # Helpers for binary codes diff --git a/test/test_stabs.jl b/test/test_stabs.jl index 1324c22d3..d415621ea 100644 --- a/test/test_stabs.jl +++ b/test/test_stabs.jl @@ -61,9 +61,6 @@ @test mixed_destab_looks_good(mds) estab = stabilizerview(md)⊗s @test canonicalize!(copy(stabilizerview(mds))) == canonicalize!(estab) - d = random_destabilizer(n) - sd = random_stabilizer(n)⊗random_destabilizer(n) - @test mixed_destab_looks_good(sd) end end