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

`embed(::NotCompositeBasis, 1, operator)`

Open Krastanov opened this issue 1 year ago • 2 comments

I have some generic code looking like this:

embed(SpinBasis(1//2)^n, i, gate)

that occasionally at runtime ends up being embed(SpinBasis(1//2), i, gate) which fails.

embed expects a composite basis and basis^1 autosimplifies to basis, so the generic code above fails.

We need a small stub distpatch for these "do not operation" edge cases.

Krastanov avatar Apr 12 '24 13:04 Krastanov

My first impression is a simple dispatch like embed(b::Basis, indices, ops) = ops is enough. Am I right?

a-eghrari avatar May 13 '24 11:05 a-eghrari

Yes, but I am worried something as simple would cause surprises down the line. Having indices == 1 || indices == (1,) || indices == [1] with a clear error message would be safer.

Also, ops should probably be typed, to avoid type piracy against QuantumInterface.jl

Krastanov avatar May 13 '24 12:05 Krastanov