From dd5cfeb7598dd1a5014580569c85b1b3f94e0dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E8=B5=84=E4=BC=9F?= <> Date: Mon, 8 Jun 2026 04:08:55 +0800 Subject: [PATCH 1/5] Add lazy option to QuantumOpticsRepr --- src/express.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/express.jl b/src/express.jl index c088c27..1812c53 100644 --- a/src/express.jl +++ b/src/express.jl @@ -22,10 +22,16 @@ express(s, repr::AbstractRepresentation) = express(s, repr, UseAsState()) # Commonly used representations -- interfaces for each one defined in separate packages ## -"""Representation using kets, bras, density matrices, and superoperators governed by `QuantumOptics.jl`.""" +"""Representation using kets, bras, density matrices, and superoperators governed by `QuantumOptics.jl`. + +Set `lazy=true` to request structure-preserving lazy operators where supported by +the target package. +""" Base.@kwdef struct QuantumOpticsRepr <: AbstractRepresentation cutoff::Int = 2 + lazy::Bool = false end +QuantumOpticsRepr(cutoff::Int) = QuantumOpticsRepr(cutoff=cutoff) """Similar to `QuantumOpticsRepr`, but using trajectories instead of superoperators.""" struct QuantumMCRepr <: AbstractRepresentation end """Representation using tableaux governed by `QuantumClifford.jl`""" @@ -33,4 +39,4 @@ struct CliffordRepr <: AbstractRepresentation end """Representation using Gaussian phase space formalism governed by `Gabs.jl`.""" struct GabsRepr{B} <: AbstractRepresentation basis::B -end \ No newline at end of file +end From bb85c7b490f3b7b9bfdb4cf31984377545c008e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E8=B5=84=E4=BC=9F?= <> Date: Mon, 8 Jun 2026 04:11:16 +0800 Subject: [PATCH 2/5] Update changelog for lazy QuantumOpticsRepr --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa9af19..0836d3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # News +## v0.4.3 - 2026-06-08 + +- Add a `lazy` option to `QuantumOpticsRepr`. + ## v0.4.2 - 2025-11-29 - Define `commutator` and `anticommutator`. From 112bfd2f49164e98747c2edae661034750d4d437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E8=B5=84=E4=BC=9F?= <> Date: Mon, 8 Jun 2026 06:01:56 +0800 Subject: [PATCH 3/5] Avoid kwdef for QuantumOpticsRepr --- src/express.jl | 7 ++++--- test/test_bases.jl | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/express.jl b/src/express.jl index 1812c53..1c304fd 100644 --- a/src/express.jl +++ b/src/express.jl @@ -27,10 +27,11 @@ express(s, repr::AbstractRepresentation) = express(s, repr, UseAsState()) Set `lazy=true` to request structure-preserving lazy operators where supported by the target package. """ -Base.@kwdef struct QuantumOpticsRepr <: AbstractRepresentation - cutoff::Int = 2 - lazy::Bool = false +struct QuantumOpticsRepr <: AbstractRepresentation + cutoff::Int + lazy::Bool end +QuantumOpticsRepr(; cutoff::Int=2, lazy::Bool=false) = QuantumOpticsRepr(cutoff, lazy) QuantumOpticsRepr(cutoff::Int) = QuantumOpticsRepr(cutoff=cutoff) """Similar to `QuantumOpticsRepr`, but using trajectories instead of superoperators.""" struct QuantumMCRepr <: AbstractRepresentation end diff --git a/test/test_bases.jl b/test/test_bases.jl index c480d41..91bf189 100644 --- a/test/test_bases.jl +++ b/test/test_bases.jl @@ -53,3 +53,14 @@ comp2 = tensor(b2, b1, b3) @test !multiplicable(comp1, b1 ⊗ b2 ⊗ NLevelBasis(prod(b3.shape))) end # testset + +@testset "representations" begin + @test QuantumInterface.QuantumOpticsRepr().cutoff == 2 + @test QuantumInterface.QuantumOpticsRepr().lazy == false + @test QuantumInterface.QuantumOpticsRepr(5).cutoff == 5 + @test QuantumInterface.QuantumOpticsRepr(5).lazy == false + @test QuantumInterface.QuantumOpticsRepr(lazy=true).cutoff == 2 + @test QuantumInterface.QuantumOpticsRepr(lazy=true).lazy == true + @test QuantumInterface.QuantumOpticsRepr(cutoff=4, lazy=true).cutoff == 4 + @test QuantumInterface.QuantumOpticsRepr(cutoff=4, lazy=true).lazy == true +end From 2c156b3f4253fa53f0246b86556c2eb8a22f5ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E8=B5=84=E4=BC=9F?= <> Date: Mon, 8 Jun 2026 06:10:32 +0800 Subject: [PATCH 4/5] Cover QuantumOpticsRepr constructors --- test/test_bases.jl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/test_bases.jl b/test/test_bases.jl index 91bf189..3dc00cd 100644 --- a/test/test_bases.jl +++ b/test/test_bases.jl @@ -1,6 +1,6 @@ using Test using QuantumInterface: tensor, ⊗, ptrace, reduced, permutesystems, multiplicable -using QuantumInterface: GenericBasis, CompositeBasis, NLevelBasis, FockBasis +using QuantumInterface: GenericBasis, CompositeBasis, NLevelBasis, FockBasis, QuantumOpticsRepr @testset "basis" begin @@ -55,12 +55,12 @@ comp2 = tensor(b2, b1, b3) end # testset @testset "representations" begin - @test QuantumInterface.QuantumOpticsRepr().cutoff == 2 - @test QuantumInterface.QuantumOpticsRepr().lazy == false - @test QuantumInterface.QuantumOpticsRepr(5).cutoff == 5 - @test QuantumInterface.QuantumOpticsRepr(5).lazy == false - @test QuantumInterface.QuantumOpticsRepr(lazy=true).cutoff == 2 - @test QuantumInterface.QuantumOpticsRepr(lazy=true).lazy == true - @test QuantumInterface.QuantumOpticsRepr(cutoff=4, lazy=true).cutoff == 4 - @test QuantumInterface.QuantumOpticsRepr(cutoff=4, lazy=true).lazy == true + @test QuantumOpticsRepr().cutoff == 2 + @test QuantumOpticsRepr().lazy == false + @test QuantumOpticsRepr(5).cutoff == 5 + @test QuantumOpticsRepr(5).lazy == false + @test QuantumOpticsRepr(lazy=true).cutoff == 2 + @test QuantumOpticsRepr(lazy=true).lazy == true + @test QuantumOpticsRepr(cutoff=4, lazy=true).cutoff == 4 + @test QuantumOpticsRepr(cutoff=4, lazy=true).lazy == true end From 472d11564daef5c55d1a0b93ba1e5699f4de1670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E8=B5=84=E4=BC=9F?= <> Date: Mon, 8 Jun 2026 06:13:02 +0800 Subject: [PATCH 5/5] Bump version for lazy QuantumOpticsRepr --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2029043..4b0e668 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "QuantumInterface" uuid = "5717a53b-5d69-4fa3-b976-0bf2f97ca1e5" authors = ["QuantumInterface.jl contributors"] -version = "0.4.2" +version = "0.4.3" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"