diff --git a/.gitignore b/.gitignore index 8b2f032..7523886 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ JuliaLocalPreferences.toml docs/src/examples/jupyter_notebooks/.ipynb_checkpoints docs/Manifest.toml benchmarks_output.json +.codex \ No newline at end of file diff --git a/Project.toml b/Project.toml index 8123ba3..a5df224 100644 --- a/Project.toml +++ b/Project.toml @@ -18,12 +18,13 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b" [compat] -# Aqua = "0.8" -# CheckConcreteStructs = "0.1" +Aqua = "0.8" +CheckConcreteStructs = "0.1" DataInterpolations = "8" FunctionWrappers = "1" DiffEqNoiseProcess = "5.27.0" -# ExplicitImports = "1.12" +ExplicitImports = "1.11" +JET = "0.9.18, 0.10, 0.11" LinearAlgebra = "1.10" ModelingToolkit = "10" NumericalIntegration = "0.3" @@ -31,7 +32,7 @@ OrdinaryDiffEq = "6" QuantumCumulants = "0.4" QuantumOptics = "1" QuantumOpticsBase = "0.4, 0.5" -SecondQuantizedAlgebra = "0.4.4" +SecondQuantizedAlgebra = "0.4.5" SpecialFunctions = "2" StaticArrays = "1" Symbolics = "6" @@ -41,11 +42,12 @@ julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" -# CheckConcreteStructs = "73c92db5-9da6-4938-911a-6443a7e94a58" -# ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" +CheckConcreteStructs = "73c92db5-9da6-4938-911a-6443a7e94a58" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" +JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" QuantumCumulants = "35bcea6d-e19f-57db-af74-8011de6c7255" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] #, "QuantumCumulants", "Aqua", "ExplicitImports", "CheckConcreteStructs"] +test = ["Test", "Aqua", "ExplicitImports", "JET", "CheckConcreteStructs"] #, "QuantumCumulants" diff --git a/TODOs.md b/TODOs.md index cb2d374..c91095f 100644 --- a/TODOs.md +++ b/TODOs.md @@ -1,15 +1,9 @@ # MAIN TODO - LIST: -- [ ] clean up - - [x] rm QC.jl - - [ ] types - - [ ] rename translate_qo (to to_numerics ?) - - [ ] speed up derivation - - [ ] examples - [ ] Multi-mode Dicke state superradiance (https://journals.aps.org/pra/abstract/10.1103/PhysRevA.103.033713) - - [ ] SUPER example (Johannes) - - [ ] pulse delay advanced example (Victor paper) + - [ ] SUPER example + - [ ] pulse delay advanced example - [x] feedback reduction (see SLH paper) - [ ] cumulants correlation matrix modes - [ ] H_loop in example 09-1 is not simplified correctly on the docu (locally it is fine; pkg versions) @@ -25,30 +19,24 @@ - [ ] u_Gaussian, v_Gaussian; slower? - [ ] more functionalities - - [x] feedback reduction + - [ ] pulse delay - [ ] better method for u_eff and v_eff (Victor) - - [ ] interaction picture (Victor paper) - - [ ] general expression for A(t) - - [ ] pulse delay (Victor paper) - - [x] two_time_corr_matrix for Ls const (see example 02-2) - -- [x] Formatter/SpellCheck - -- [ ] JET - -- [ ] Aqua +- [] docu + - u_eff and v_eff theory + - development status ## Additional TODOs -- [ ] SLH more specific types - - [ ] AbstractVector{<:QTerm} -- [ ] directly use gu(t) without substitution? (think about iscall) - [ ] u_eff and v_eff equation (PRA 2020, appendix) theory, API, implementation +- [ ] rename translate_qo (to to_numerics ?) ## DONE +- [x] rm QC.jl +- [x] types +- [x] speed up derivation - [x] Translate function: - [x] Try TimeDependentSums again (after solving the gu(t) mistake/problem) [~factor 2 slower!] @@ -95,3 +83,11 @@ - [x] arg u not needed?! - [x] analytic expression for u=v - [x] kwarg for adjoint replacement in substitute_operators + - [x] feedback reduction + - [x] interaction picture + - [x] general expression for A(t) + - [x] two_time_corr_matrix for Ls const (see example 02-2) + +- [x] Formatter/SpellCheck +- [x] JET +- [x] Aqua \ No newline at end of file diff --git a/src/QuantumInputOutput.jl b/src/QuantumInputOutput.jl index 228e252..1bd7c73 100644 --- a/src/QuantumInputOutput.jl +++ b/src/QuantumInputOutput.jl @@ -1,21 +1,18 @@ module QuantumInputOutput -using SecondQuantizedAlgebra -using QuantumOpticsBase -using QuantumOptics -using SymbolicUtils: - SymbolicUtils, substitute, BasicSymbolic, operation, arguments, iscall, simplify, expand -using Symbolics +using SecondQuantizedAlgebra: SecondQuantizedAlgebra, QSym, to_numeric +using QuantumOpticsBase: QuantumOpticsBase, expect, basis, dagger, sparse +using QuantumOptics: QuantumOptics, timeevolution +using SymbolicUtils: SymbolicUtils, substitute, BasicSymbolic, arguments, simplify, expand +using Symbolics: Symbolics, build_function using SpecialFunctions: erf using DataInterpolations: LinearInterpolation, ExtrapolationType using NumericalIntegration: cumul_integrate using LinearAlgebra: LinearAlgebra, I, mul! -using OrdinaryDiffEq -using StaticArrays -using FunctionWrappers +using OrdinaryDiffEq: OrdinaryDiffEq, ODEProblem, Tsit5, solve +using StaticArrays: StaticArrays, SMatrix, SVector +using FunctionWrappers: FunctionWrappers, FunctionWrapper -import QuantumOpticsBase: expect -import SecondQuantizedAlgebra: numeric_average const SQA = SecondQuantizedAlgebra export SLH, diff --git a/src/SLH.jl b/src/SLH.jl index fd68d9d..20a0cfb 100644 --- a/src/SLH.jl +++ b/src/SLH.jl @@ -1,4 +1,4 @@ -using StaticArrays +using StaticArrays: StaticArrays, SMatrix, SVector using FunctionWrappers: FunctionWrapper # NOTE: FunctionWrapper is callable but NOT <: Function. @@ -451,6 +451,3 @@ function _feedback_maps(n::Int, connections) end return mapped end - -Base.length(h::SecondQuantizedAlgebra.ConcreteHilbertSpace) = 1 -Base.length(h::ProductSpace) = length(h.spaces) diff --git a/src/utils.jl b/src/utils.jl index ba06847..30a136c 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1,16 +1,3 @@ -# move to SQA -function numeric_average(op::SQA.QNumber, state::Vector; kwargs...) - op_num = sparse(to_numeric(op, state[1]; kwargs...)) - return QuantumOpticsBase.expect(op_num, state) -end -function numeric_average(avg::Average, state::Vector; kwargs...) - op = undo_average(avg) - return numeric_average(op, state; kwargs...) -end - -expect(avg::Average, state; kwargs...) = numeric_average(avg, state; kwargs...) -expect(op::SQA.QNumber, state; kwargs...) = numeric_average(op, state; kwargs...) - """ substitute_operators(op, dict::Dict; replace_adjoint=true) @@ -38,6 +25,6 @@ end function _extend_with_adjoint(dict::Dict) pairs_ = collect(dict) - adj_pairs = [SQA.adjoint(k) => SQA.adjoint(v) for (k, v) in pairs_] + adj_pairs = [Base.adjoint(k) => Base.adjoint(v) for (k, v) in pairs_] return Dict(vcat(pairs_, adj_pairs)) end diff --git a/test/runtests.jl b/test/runtests.jl index dafa4ec..0a14d45 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,5 @@ names = [ + "test_code_quality.jl", "test_SLH.jl", "test_feedback.jl", "test_translate.jl", diff --git a/test/test_code_quality.jl b/test/test_code_quality.jl new file mode 100644 index 0000000..caec107 --- /dev/null +++ b/test/test_code_quality.jl @@ -0,0 +1,37 @@ +using QuantumInputOutput, Test + +@testset "best practices" begin + using Aqua + + Aqua.test_ambiguities([QuantumInputOutput]; broken = false) + Aqua.test_piracies(QuantumInputOutput; broken = false) + Aqua.test_all(QuantumInputOutput; ambiguities = false, piracies = false) +end + +@testset "ExplicitImports" begin + using ExplicitImports + + @test check_no_implicit_imports(QuantumInputOutput) == nothing + @test check_all_explicit_imports_via_owners(QuantumInputOutput) == nothing + @test check_no_stale_explicit_imports(QuantumInputOutput) == nothing + @test check_all_qualified_accesses_via_owners(QuantumInputOutput) == nothing + @test check_no_self_qualified_accesses(QuantumInputOutput) == nothing +end + +if isempty(VERSION.prerelease) + @testset "Code linting" begin + using JET + + rep = report_package(QuantumInputOutput) + @show rep + @test length(JET.get_reports(rep)) < 74 # TODO + end +end + +@testset "Concretely typed" begin + import QuantumInputOutput as QIO + using CheckConcreteStructs + + all_concrete(typeof(QIO.SLH(1, 0, 0))) # TODO + all_concrete(QIO.Gaussian) +end