QuantumCumulants.jl icon indicating copy to clipboard operation
QuantumCumulants.jl copied to clipboard

metadata function for QAdd

Open oameye opened this issue 1 year ago • 1 comments

The package defines a function to extract the metadata of the QAdd type but QAdd does not have a metadata field.

https://github.com/qojulia/QuantumCumulants.jl/blob/1d144b1811596057a4bd57eee601669db61cc8ac/src/qnumber.jl#L232

The function is used when you try to use Symbolics.expand on a QAdd expression:

using QuantumCumulant
using Symbolics

h = FockSpace(:cavity)

@qnumbers a::Destroy(h)

expr = (a'+a) |> simplify
expr |> expand

oameye avatar Apr 28 '24 19:04 oameye

Thanks for the report! The fact that the metadata is missing here is definitely an oversight on our end. However, that's not the whole story. I wouldn't expect expand to work properly on QNumber types right now. What we also need is an overload to expand similar to what we are doing with simplify so Symbolics can work on numbers. Something like this:

function Symbolics.expand(q::QTerm)
    q |> average |> expand |> undo_average
end

david-pl avatar Apr 29 '24 15:04 david-pl