Skip to content

Commit

Permalink
updates from TermInterface v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
apkille committed Jun 12, 2024
1 parent 84bd19d commit 12fe212
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 44 deletions.
4 changes: 2 additions & 2 deletions ext/QuantumCliffordExt/QuantumCliffordExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using QuantumSymbolics: HGate, XGate, YGate, ZGate, CPHASEGate, CNOTGate,
Symbolic
import QuantumSymbolics: express, express_nolookup, express_from_cache
using TermInterface
using TermInterface: istree, exprhead, operation, arguments, similarterm, metadata
using TermInterface: isexpr, head, operation, arguments, metadata

using QuantumClifford

Expand All @@ -24,7 +24,7 @@ express_nolookup(s::XBasisState, ::CliffordRepr) = (_qc_s₊,_qc_s₋)[s.idx]
express_nolookup(s::YBasisState, ::CliffordRepr) = (_qc_i₊,_qc_i₋)[s.idx]
express_nolookup(s::ZBasisState, ::CliffordRepr) = (_qc_l,_qc_h)[s.idx]
function express_nolookup(s::Symbolic{T}, repr::CliffordRepr) where {T<:Union{AbstractKet,AbstractOperator}}
if istree(s) && operation(s)==
if isexpr(s) && operation(s)==

Check warning on line 27 in ext/QuantumCliffordExt/QuantumCliffordExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/QuantumCliffordExt/QuantumCliffordExt.jl#L27

Added line #L27 was not covered by tests
#operation(s)(express.(arguments(s), (repr,))...) # TODO this does not work because QuantumClifford.⊗ is different from ⊗
QuantumClifford.tensor(express.(arguments(s), (repr,))...)
else
Expand Down
2 changes: 1 addition & 1 deletion ext/QuantumOpticsExt/QuantumOpticsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using QuantumSymbolics:
qubit_basis, inf_fock_basis
import QuantumSymbolics: express, express_nolookup
using TermInterface
using TermInterface: istree, exprhead, operation, arguments, similarterm, metadata
using TermInterface: isexpr, head, operation, arguments, metadata

const _b2 = SpinBasis(1//2)
const _l0 = spinup(_b2)
Expand Down
6 changes: 3 additions & 3 deletions src/QSymbolicsBase/QSymbolicsBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Symbolics: simplify
using SymbolicUtils
import SymbolicUtils: Symbolic, _isone, flatten_term, isnotflat, Chain, Fixpoint
using TermInterface
import TermInterface: istree, exprhead, operation, arguments, similarterm, metadata
import TermInterface: isexpr, head, iscall, children, operation, arguments, metadata

using LinearAlgebra
import LinearAlgebra: eigvecs
Expand Down Expand Up @@ -47,7 +47,7 @@ end
function countmap_flatten(samples, flattenhead)
counts = Dict{Any,Any}()
for s in samples
if istree(s) && s isa flattenhead # TODO Could you use the TermInterface `operation` here instead of `flattenhead`?
if isexpr(s) && s isa flattenhead # TODO Could you use the TermInterface `operation` here instead of `flattenhead`?
coef, term = arguments(s)
counts[term] = get(counts, term, 0)+coef
else
Expand Down Expand Up @@ -134,7 +134,7 @@ Base.:(-)(x::SymQObj,y::SymQObj) = x + (-y)

function Base.isequal(x::X,y::Y) where {X<:SymQObj, Y<:SymQObj}
if X==Y
if istree(x)
if isexpr(x)
if operation(x)==operation(y)
ax,ay = arguments(x),arguments(y)
(length(ax) == length(ay)) && all(zip(ax,ay)) do xy isequal(xy...) end
Expand Down
22 changes: 14 additions & 8 deletions src/QSymbolicsBase/basic_ops_homogeneous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct SOperator <: Symbolic{AbstractKet}
basis::Basis
end
const SymQ = Union{SKet, SOperator}
istree(::SymQ) = false
isexpr(::SymQ) = false

Check warning on line 12 in src/QSymbolicsBase/basic_ops_homogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_homogeneous.jl#L12

Added line #L12 was not covered by tests
metadata(::SymQ) = nothing
basis(x::SymQ) = x.basis

Expand All @@ -24,10 +24,12 @@ Base.show(io::IO, x::SymQObj) = print(io, symbollabel(x)) # fallback that probab
obj
SScaled{S}(c,k) where S = _isone(c) ? k : new{S}(c,k)
end
istree(::SScaled) = true
arguments(x::SScaled) = [x.coeff, x.obj]
isexpr(::SScaled) = true
iscall(::SScaled) = true

Check warning on line 28 in src/QSymbolicsBase/basic_ops_homogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_homogeneous.jl#L28

Added line #L28 was not covered by tests
arguments(x::SScaled) = [x.coeff,x.obj]
operation(x::SScaled) = *
exprhead(x::SScaled) = :*
head(x::SScaled) = :*
children(x::SScaled) = [:*,x.coeff,x.obj]

Check warning on line 32 in src/QSymbolicsBase/basic_ops_homogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_homogeneous.jl#L31-L32

Added lines #L31 - L32 were not covered by tests
Base.:(*)(c, x::Symbolic{T}) where {T<:QObj} = SScaled{T}(c,x)
Base.:(*)(x::Symbolic{T}, c) where {T<:QObj} = SScaled{T}(c,x)
Base.:(/)(x::Symbolic{T}, c) where {T<:QObj} = SScaled{T}(1/c,x)
Expand Down Expand Up @@ -63,10 +65,12 @@ end
dict
SAdd{S}(d) where S = length(d)==1 ? SScaled{S}(reverse(first(d))...) : new{S}(d)
end
istree(::SAdd) = true
isexpr(::SAdd) = true
iscall(::SAdd) = true

Check warning on line 69 in src/QSymbolicsBase/basic_ops_homogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_homogeneous.jl#L69

Added line #L69 was not covered by tests
arguments(x::SAdd) = [SScaledKet(v,k) for (k,v) in pairs(x.dict)]
operation(x::SAdd) = +
exprhead(x::SAdd) = :+
head(x::SAdd) = :+
children(x::SAdd) = [:+,SScaledKet(v,k) for (k,v) in pairs(x.dict)]

Check warning on line 73 in src/QSymbolicsBase/basic_ops_homogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_homogeneous.jl#L72-L73

Added lines #L72 - L73 were not covered by tests
Base.:(+)(xs::Vararg{Symbolic{T},N}) where {T<:QObj,N} = SAdd{T}(countmap_flatten(xs, SScaled{T}))
Base.:(+)(xs::Vararg{Symbolic{<:QObj},0}) = 0 # to avoid undefined type parameters issue in the above method
basis(x::SAdd) = basis(first(x.dict).first)
Expand All @@ -86,10 +90,12 @@ Base.show(io::IO, x::SAddBra) = print(io, "("*join(map(string, arguments(x)),"+"
coeff * new{S}(cleanterms)
end
end
istree(::STensor) = true
isexpr(::STensor) = true
iscall(::STensor) = true

Check warning on line 94 in src/QSymbolicsBase/basic_ops_homogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_homogeneous.jl#L94

Added line #L94 was not covered by tests
arguments(x::STensor) = x.terms
operation(x::STensor) =
exprhead(x::STensor) = :
head(x::STensor) = :
children(x::STensor) = pushfirst!(x.terms,:)

Check warning on line 98 in src/QSymbolicsBase/basic_ops_homogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_homogeneous.jl#L97-L98

Added lines #L97 - L98 were not covered by tests
(xs::Symbolic{T}...) where {T<:QObj} = STensor{T}(collect(xs))
basis(x::STensor) = tensor(basis.(x.terms)...)

Expand Down
30 changes: 20 additions & 10 deletions src/QSymbolicsBase/basic_ops_inhomogeneous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
op
ket
end
istree(::SApplyKet) = true
isexpr(::SApplyKet) = true
iscall(::SApplyKet) = true

Check warning on line 9 in src/QSymbolicsBase/basic_ops_inhomogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_inhomogeneous.jl#L9

Added line #L9 was not covered by tests
arguments(x::SApplyKet) = [x.op,x.ket]
operation(x::SApplyKet) = *
exprhead(x::SApplyKet) = :*
head(x::SApplyKet) = :*
children(x::SApplyKet) = [:*,x.op,x.ket]

Check warning on line 13 in src/QSymbolicsBase/basic_ops_inhomogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_inhomogeneous.jl#L12-L13

Added lines #L12 - L13 were not covered by tests
Base.:(*)(op::Symbolic{AbstractOperator}, k::Symbolic{AbstractKet}) = SApplyKet(op,k)
Base.show(io::IO, x::SApplyKet) = begin print(io, x.op); print(io, x.ket) end
basis(x::SApplyKet) = basis(x.ket)
Expand All @@ -18,10 +20,12 @@ basis(x::SApplyKet) = basis(x.ket)
bra
op
end
istree(::SApplyBra) = true
isexpr(::SApplyBra) = true
iscall(::SApplyBra) = true

Check warning on line 24 in src/QSymbolicsBase/basic_ops_inhomogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_inhomogeneous.jl#L23-L24

Added lines #L23 - L24 were not covered by tests
arguments(x::SApplyBra) = [x.bra,x.op]
operation(x::SApplyBra) = *
exprhead(x::SApplyBra) = :*
head(x::SApplyBra) = :*
children(x::SApplyBra) = [:*,x.bra,x.op]

Check warning on line 28 in src/QSymbolicsBase/basic_ops_inhomogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_inhomogeneous.jl#L27-L28

Added lines #L27 - L28 were not covered by tests
Base.:(*)(b::Symbolic{AbstractBra}, op::Symbolic{AbstractOperator}) = SApplyBra(b,op)
Base.show(io::IO, x::SApplyBra) = begin print(io, x.bra); print(io, x.op) end
basis(x::SApplyBra) = basis(x.bra)
Expand All @@ -31,10 +35,12 @@ basis(x::SApplyBra) = basis(x.bra)
bra
ket
end
istree(::SBraKet) = true
isexpr(::SBraKet) = true
iscall(::SBraKet) = true

Check warning on line 39 in src/QSymbolicsBase/basic_ops_inhomogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_inhomogeneous.jl#L38-L39

Added lines #L38 - L39 were not covered by tests
arguments(x::SBraKet) = [x.bra,x.ket]
operation(x::SBraKet) = *
exprhead(x::SBraKet) = :*
head(x::SBraKet) = :*
children(x::SBraKet) = [:*,x.bra,x.ket]

Check warning on line 43 in src/QSymbolicsBase/basic_ops_inhomogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_inhomogeneous.jl#L42-L43

Added lines #L42 - L43 were not covered by tests
Base.:(*)(b::Symbolic{AbstractBra}, k::Symbolic{AbstractKet}) = SBraKet(b,k)
function Base.show(io::IO, x::SBraKet)
print(io,x.bra)
Expand All @@ -46,10 +52,12 @@ end
sop
op
end
istree(::SApplyOp) = true
isexpr(::SApplyOp) = true
iscall(::SApplyOp) = true

Check warning on line 56 in src/QSymbolicsBase/basic_ops_inhomogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_inhomogeneous.jl#L56

Added line #L56 was not covered by tests
arguments(x::SApplyOp) = [x.sop,x.op]
operation(x::SApplyOp) = *
exprhead(x::SApplyOp) = :*
head(x::SApplyOp) = :*
children(x::SApplyOp) = [:*,x.sop,x.op]

Check warning on line 60 in src/QSymbolicsBase/basic_ops_inhomogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_inhomogeneous.jl#L59-L60

Added lines #L59 - L60 were not covered by tests
Base.:(*)(sop::Symbolic{AbstractSuperOperator}, op::Symbolic{AbstractOperator}) = SApplyOp(sop,op)
Base.:(*)(sop::Symbolic{AbstractSuperOperator}, k::Symbolic{AbstractKet}) = SApplyOp(sop,SProjector(k))
Base.show(io::IO, x::SApplyOp) = begin print(io, x.sop); print(io, x.op) end
Expand All @@ -60,10 +68,12 @@ basis(x::SApplyOp) = basis(x.op)
ket
bra
end
istree(::SOuterKetBra) = true
isexpr(::SOuterKetBra) = true
iscall(::SOuterKetBra) = true

Check warning on line 72 in src/QSymbolicsBase/basic_ops_inhomogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_inhomogeneous.jl#L71-L72

Added lines #L71 - L72 were not covered by tests
arguments(x::SOuterKetBra) = [x.ket,x.bra]
operation(x::SOuterKetBra) = *
exprhead(x::SOuterKetBra) = :*
head(x::SOuterKetBra) = :*
children(x::SOuterKetBra) = [:*,x.ket,x.bra]

Check warning on line 76 in src/QSymbolicsBase/basic_ops_inhomogeneous.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/basic_ops_inhomogeneous.jl#L75-L76

Added lines #L75 - L76 were not covered by tests
Base.:(*)(k::Symbolic{AbstractKet}, b::Symbolic{AbstractBra}) = SOuterKetBra(k,b)
Base.:(*)(k::SScaledKet, b::Symbolic{AbstractBra}) = k.coeff*SOuterKetBra(k.obj,b)
Base.:(*)(k::Symbolic{AbstractKet}, b::SScaledBra) = b.coeff*SOuterKetBra(k,b.obj)
Expand Down
2 changes: 1 addition & 1 deletion src/QSymbolicsBase/express.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ express_nolookup(state, ::QuantumMCRepr) = express_nolookup(state, QuantumOptics
express(state) = state

function express_nolookup(s, repr::AbstractRepresentation)
if istree(s)
if isexpr(s)
operation(s)(express.(arguments(s), (repr,))...)
else
error("Encountered an object $(s) of type $(typeof(s)) that can not be converted to $(repr) representation") # TODO make a nice error type
Expand Down
8 changes: 4 additions & 4 deletions src/QSymbolicsBase/latexify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ end
return LaTeXString("\\hat $(symbollabel(x))")
end
@latexrecipe function f(x::SDagger)
if istree(x.ket)
if isexpr(x.ket)

Check warning on line 31 in src/QSymbolicsBase/latexify.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/latexify.jl#L31

Added line #L31 was not covered by tests
return Expr(:latexifymerge, "\\left( ", x.ket, "\\right)^\\dagger")
else
return Expr(:latexifymerge, "\\left\\langle ", symbollabel(x), "\\right|")
Expand All @@ -48,14 +48,14 @@ end
end

function _toexpr(x)
if istree(x)
return Expr(:call, exprhead(x), arguments(x)...)
if isexpr(x)
return Expr(:call, head(x), arguments(x)...)

Check warning on line 52 in src/QSymbolicsBase/latexify.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/latexify.jl#L51-L52

Added lines #L51 - L52 were not covered by tests
else
x
end
end
function _addparen(x)
if istree(x)
if isexpr(x)

Check warning on line 58 in src/QSymbolicsBase/latexify.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/latexify.jl#L58

Added line #L58 was not covered by tests
return Expr(:latexifymerge, "\\left(", x, "\\right)")
else
return x
Expand Down
26 changes: 15 additions & 11 deletions src/QSymbolicsBase/predefined.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
##

abstract type SpecialKet <: Symbolic{AbstractKet} end
istree(::SpecialKet) = false
isexpr(::SpecialKet) = false
basis(x::SpecialKet) = x.basis
Base.show(io::IO, x::SpecialKet) = print(io, "|$(symbollabel(x))")

Expand Down Expand Up @@ -84,8 +84,8 @@ abstract type AbstractSingleQubitOp <: Symbolic{AbstractOperator} end
abstract type AbstractTwoQubitOp <: Symbolic{AbstractOperator} end
abstract type AbstractSingleQubitGate <: AbstractSingleQubitOp end # TODO maybe an IsUnitaryTrait is a better choice
abstract type AbstractTwoQubitGate <: AbstractTwoQubitOp end
istree(::AbstractSingleQubitGate) = false
istree(::AbstractTwoQubitGate) = false
isexpr(::AbstractSingleQubitGate) = false
isexpr(::AbstractTwoQubitGate) = false

Check warning on line 88 in src/QSymbolicsBase/predefined.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/predefined.jl#L88

Added line #L88 was not covered by tests
basis(::AbstractSingleQubitGate) = qubit_basis
basis(::AbstractTwoQubitGate) = qubit_basisqubit_basis
Base.show(io::IO, x::AbstractSingleQubitOp) = print(io, "$(symbollabel(x))")
Expand All @@ -97,7 +97,7 @@ Base.show(io::IO, x::AbstractTwoQubitOp) = print(io, "$(symbollabel(x))")
indices::Vector{Int}
basis::Basis
end
istree(::OperatorEmbedding) = true
isexpr(::OperatorEmbedding) = true

Check warning on line 100 in src/QSymbolicsBase/predefined.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/predefined.jl#L100

Added line #L100 was not covered by tests

@withmetadata struct XGate <: AbstractSingleQubitGate end
eigvecs(g::XGate) = [X1,X2]
Expand Down Expand Up @@ -157,7 +157,7 @@ const CPHASE = CPHASEGate()

abstract type AbstractSingleBosonOp <: Symbolic{AbstractOperator} end
abstract type AbstractSingleBosonGate <: AbstractSingleBosonOp end # TODO maybe an IsUnitaryTrait is a better choice
istree(::AbstractSingleBosonGate) = false
isexpr(::AbstractSingleBosonGate) = false

Check warning on line 160 in src/QSymbolicsBase/predefined.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/predefined.jl#L160

Added line #L160 was not covered by tests
basis(::AbstractSingleBosonGate) = inf_fock_basis

@withmetadata struct NumberOp <: AbstractSingleBosonOp end
Expand Down Expand Up @@ -193,10 +193,12 @@ Operator(dim=2x2)
@withmetadata struct SProjector <: Symbolic{AbstractOperator}
ket::Symbolic{AbstractKet} # TODO parameterize
end
istree(::SProjector) = true
isexpr(::SProjector) = true
iscall(::SProjector) = true

Check warning on line 197 in src/QSymbolicsBase/predefined.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/predefined.jl#L197

Added line #L197 was not covered by tests
arguments(x::SProjector) = [x.ket]
operation(x::SProjector) = projector
exprhead(x::SProjector) = :projector
head(x::SProjector) = :projector
children(x::SProjector) = [:projector,x.ket]

Check warning on line 201 in src/QSymbolicsBase/predefined.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/predefined.jl#L200-L201

Added lines #L200 - L201 were not covered by tests
projector(x::Symbolic{AbstractKet}) = SProjector(x)
basis(x::SProjector) = basis(x.ket)
function Base.show(io::IO, x::SProjector)
Expand All @@ -209,10 +211,12 @@ end
@withmetadata struct SDagger <: Symbolic{AbstractBra}
ket::Symbolic{AbstractKet}
end
istree(::SDagger) = true
isexpr(::SDagger) = true
iscall(::SDagger) = true

Check warning on line 215 in src/QSymbolicsBase/predefined.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/predefined.jl#L215

Added line #L215 was not covered by tests
arguments(x::SDagger) = [x.ket]
operation(x::SDagger) = dagger
exprhead(x::SDagger) = :dagger
head(x::SDagger) = :dagger
children(x::SDagger) = [:dagger, x.ket]

Check warning on line 219 in src/QSymbolicsBase/predefined.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/predefined.jl#L218-L219

Added lines #L218 - L219 were not covered by tests
dagger(x::Symbolic{AbstractKet}) = SDagger(x)
dagger(x::SScaledKet) = SScaledBra(x.coeff, dagger(x.obj))
dagger(x::SAddKet) = SAddBra(Dict(dagger(k)=>v for (k,v) in pairs(x.dict)))
Expand Down Expand Up @@ -250,7 +254,7 @@ julia> express(MixedState(X1⊗X2), CliffordRepr())
end
MixedState(x::Symbolic{AbstractKet}) = MixedState(basis(x))
MixedState(x::Symbolic{AbstractOperator}) = MixedState(basis(x))
istree(::MixedState) = false
isexpr(::MixedState) = false
basis(x::MixedState) = x.basis
symbollabel(x::MixedState) = "𝕄"

Expand All @@ -269,6 +273,6 @@ Operator(dim=2x2)
end
IdentityOp(x::Symbolic{AbstractKet}) = IdentityOp(basis(x))
IdentityOp(x::Symbolic{AbstractOperator}) = IdentityOp(basis(x))
istree(::IdentityOp) = false
isexpr(::IdentityOp) = false
basis(x::IdentityOp) = x.basis
symbollabel(x::IdentityOp) = "𝕀"
2 changes: 1 addition & 1 deletion src/QSymbolicsBase/predefined_CPTP.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export PauliNoiseCPTP, DephasingCPTP, DephasingCPTP, GateCPTP

abstract type NoiseCPTP <: Symbolic{AbstractSuperOperator} end
istree(::NoiseCPTP) = false
isexpr(::NoiseCPTP) = false
basis(x::NoiseCPTP) = x.basis

"""Single-qubit Pauli noise CPTP map
Expand Down
4 changes: 2 additions & 2 deletions src/QSymbolicsBase/rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function prefactorscalings(xs)
terms = []
coeff = 1::Any
for x in xs
if istree(x) && operation(x) == *
if isexpr(x) && operation(x) == *
c,t = arguments(x)
coeff *= c
push!(terms,t)
Expand All @@ -30,7 +30,7 @@ function isnotflat_precheck(*)
operation(x) === (*) || return false
args = arguments(x)
for t in args
if istree(t) && operation(t) === (*)
if isexpr(t) && operation(t) === (*)
return true
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/extensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Ket(dim=2)
@withmetadata struct StabilizerState{T} <: Symbolic{AbstractKet} where {T}
stabilizer::T
end
istree(::StabilizerState) = false
isexpr(::StabilizerState) = false
basis(x::StabilizerState) = SpinBasis(1//2)^nqubits(x.stabilizer)
Base.show(io::IO, x::StabilizerState) = print(io, "𝒮$(num_to_sub(nqubits(x.stabilizer)))")

Expand Down

0 comments on commit 12fe212

Please sign in to comment.