diff --git a/src/average.jl b/src/average.jl index ccf0453a..3df8b577 100644 --- a/src/average.jl +++ b/src/average.jl @@ -89,9 +89,6 @@ function undo_average(t) f = SymbolicUtils.operation(t) if isequal(f,sym_average) # "===" results in false sometimes in Symbolics version > 5 return SymbolicUtils.arguments(t)[1] - elseif isequal(f, sym_csum) # TODO: is this clean? - args = map(undo_average, SymbolicUtils.arguments(t)) - return Sum(args...) else args = map(undo_average, SymbolicUtils.arguments(t)) return f(args...) @@ -150,8 +147,6 @@ function cumulant_expansion(x::SymbolicUtils.Symbolic,order::Integer;simplify=tr cumulants = [cumulant_expansion(arg,order;kwargs...) for arg in args] return f(cumulants...) end - elseif x isa AvgSums - return _cumulant_expansion(x,order;simplify,kwargs...) # basically just another cumulant_expansion dispatch else return x end diff --git a/src/indexing_sums.jl b/src/indexing_sums.jl index 2fe24031..df05ee62 100644 --- a/src/indexing_sums.jl +++ b/src/indexing_sums.jl @@ -26,6 +26,9 @@ struct CSumSym <: CNumber end csum(args...) = Sum(args...) +# SymbolicUtils.maketerm(::Type{T}, ::typeof(csum), args, metadata) where T = csum(args...) +# SymbolicUtils.maketerm(::Type{<:SymbolicUtils.BasicSymbolic}, ::typeof(csum), args, metadata) = csum(args...) + function Sum(term::SymbolicUtils.Symbolic{<:Number}, index::Index; metadata = nothing) # TODO: don't ignore metadata here # TODO: printing for CNumber sums diff --git a/test/test_indexed_meanfield.jl b/test/test_indexed_meanfield.jl index ea8dff75..b9aa639d 100644 --- a/test/test_indexed_meanfield.jl +++ b/test/test_indexed_meanfield.jl @@ -29,6 +29,9 @@ g(k) = IndexedVariable(:g,k) @test qc.get_indices(Γ_ij) == Set([i_ind, j_ind]) # Hamiltonian +@qnumbers a::Destroy(h) +σ(i,j,k) = IndexedOperator(Transition(h,:σ,i,j),k) + ex = Ω_ij*σ(2,1,i_ind)*σ(1,2,j_ind) @test has_index(ex, i_ind) @test has_index(ex, j_ind)