diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c4bc1e8..a17a31b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,10 +1,12 @@ name: CI on: + pull_request: + branches: + - main push: branches: - - unit-test - tags: '*' - pull_request: + - main + concurrency: # Skip intermediate builds: always. # Cancel intermediate builds: only if it is a pull request build. @@ -20,14 +22,15 @@ jobs: version: # - '1.8' - '1.9' + - '1.10' os: - ubuntu-latest arch: - x64 - # include: - # - os: windows-latest - # version: '1' - # arch: x64 + include: + - os: windows-latest + version: '1.10' + arch: x64 # - os: macOS-latest # version: '1' # arch: x64 @@ -40,7 +43,7 @@ jobs: - uses: julia-actions/cache@v1 - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v2 - with: - files: lcov.info \ No newline at end of file + # - uses: julia-actions/julia-processcoverage@v1 + # - uses: codecov/codecov-action@v2 + # with: + # files: lcov.info \ No newline at end of file diff --git a/ext/QuanEstimationPyExt.jl b/ext/QuanEstimationPyExt.jl index 6fa276a..d0eb0dc 100644 --- a/ext/QuanEstimationPyExt.jl +++ b/ext/QuanEstimationPyExt.jl @@ -2,8 +2,9 @@ module QuanEstimationPyExt using PythonCall using QuanEstimation np = pyimport("numpy") -# QuanEstimation.Htot(H0::PyArray, Hc::PyList, ctrl) = QuanEstimation.Htot(Matrix(H0), [Matrix(hc) for hc in Hc], ctrl) + QuanEstimation.ControlOpt(ctrl::PyList, ctrl_bound::PyList, seed::Py) = QuanEstimation.ControlOpt(pyconvert(Vector{Vector{Float64}}, ctrl), pyconvert(Vector{Float64}, ctrl_bound), seed) + QuanEstimation.Lindblad( H0::PyArray, dH::PyList, @@ -25,6 +26,29 @@ QuanEstimation.Lindblad( pyconvert(Vector, γ); kwargs..., ) + +QuanEstimation.Lindblad( + H0::PyArray, + dH::PyList, + Hc::PyList, + ctrl::PyList, + ψ0::PyList, + tspan::PyArray, + decay_opt::PyList, + γ::PyList; + kwargs..., +) = QuanEstimation.Lindblad( + pyconvert(Matrix{ComplexF64}, H0), + pyconvert(Vector{Matrix}, dH), + pyconvert(Vector{Matrix}, Hc), + pyconvert(Vector{Vector{Float64}}, ctrl), + pyconvert(Vector{ComplexF64}, ψ0), + pyconvert(Vector, tspan), + pyconvert(Vector{Matrix}, decay_opt), + pyconvert(Vector, γ); + kwargs..., +) + QuanEstimation.Lindblad( H0::PyArray, dH::PyList, @@ -42,4 +66,96 @@ QuanEstimation.Lindblad( pyconvert(Vector, γ); kwargs..., ) + +QuanEstimation.Lindblad( + H0::PyArray, + dH::PyList, + ρ0::PyArray, + tspan::PyArray, + decay_opt::PyList, + γ::PyList; + kwargs..., +) = QuanEstimation.Lindblad( + pyconvert(Matrix{ComplexF64}, H0), + pyconvert(Vector{Matrix}, dH), + pyconvert(Matrix{ComplexF64}, ρ0), + pyconvert(Vector, tspan), + pyconvert(Vector{Matrix}, decay_opt), + pyconvert(Vector, γ); + kwargs..., +) + +QuanEstimation.Lindblad( + H0::PyArray, + dH::PyList, + ψ0::PyList, + tspan::PyArray; + kwargs..., +) = QuanEstimation.Lindblad( + pyconvert(Matrix{ComplexF64}, H0), + pyconvert(Vector{Matrix}, dH), + pyconvert(Vector{ComplexF64}, ψ0), + pyconvert(Vector, tspan); + kwargs..., +) + +QuanEstimation.Lindblad( + H0::PyArray, + dH::PyList, + ρ0::PyArray, + tspan::PyArray; + kwargs..., +) = QuanEstimation.Lindblad( + pyconvert(Matrix{ComplexF64}, H0), + pyconvert(Vector{Matrix}, dH), + pyconvert(Matrix{ComplexF64}, ρ0), + pyconvert(Vector, tspan); + kwargs..., +) + +QuanEstimation.Kraus( + ρ0::PyArray, + K::PyList, + dK::PyList; + kwargs..., +) = QuanEstimation.Kraus( + pyconvert(Matrix{ComplexF64}, ρ0), + pyconvert(Vector{Matrix{ComplexF64}}, K), + pyconvert(Vector{Vector{Matrix{ComplexF64}}}, dK); + kwargs..., +) + +QuanEstimation.Kraus( + ψ0::PyList, + K::PyList, + dK::PyList; + kwargs..., +) = QuanEstimation.Kraus( + pyconvert(Vector{ComplexF64}, ψ0), + pyconvert(Vector{Matrix{ComplexF64}}, K), + pyconvert(Vector{Vector{Matrix{ComplexF64}}}, dK); + kwargs..., +) + +QuanEstimation.expm_py( + tspan::PyArray, + ρ0::AbstractMatrix, + H0::PyArray, + dH::PyList, + decay_opt::PyList, + γ::PyList, + Hc::PyList, + ctrl::PyList, +) = QuanEstimation.expm_py( + pyconvert(Vector, tspan), + pyconvert(Matrix{ComplexF64}, ρ0), + pyconvert(Matrix{ComplexF64}, H0), + pyconvert(Vector{Matrix{ComplexF64}}, dH), + pyconvert(Vector{Matrix{ComplexF64}}, decay_opt), + pyconvert(Vector, γ), + pyconvert(Vector{Matrix{ComplexF64}}, Hc), + pyconvert(Vector{Vector{Float64}}, ctrl), +) + + end diff --git a/src/Common/Common.jl b/src/Common/Common.jl index 27fd2f4..3d98f39 100644 --- a/src/Common/Common.jl +++ b/src/Common/Common.jl @@ -290,7 +290,7 @@ function initial_ctrl!(opt, ctrl0, dynamics, p_num, rng) ctrl0 = [ctrl0[i] for i in 1:p_num] end for pj in 1:length(ctrl0) - dynamics[pj].data.ctrl = ctrl0[pj] isa AbstractVector ? deepcopy(ctrl0[pj]) : [[ctrl0[pj][i, j] for j in 1:ctrl_length] for i in 1:ctrl_num] + dynamics[pj].data.ctrl = deepcopy(ctrl0[pj]) end if opt.ctrl_bound[1] == -Inf || opt.ctrl_bound[2] == Inf for pj in (length(ctrl0)+1):p_num @@ -323,7 +323,7 @@ function initial_M!(measurement0, C_all, dim, p_num, M_num, rng) measurement0 = [measurement0[i] for i in 1:p_num] end for pj in 1:length(measurement0) - C_all[pj] = measurement0[pj] isa AbstractVector ? deepcopy(measurement0[pj]) : [[measurement0[pj][i,j] for j in 1:dim] for i in 1:M_num] + C_all[pj] = deepcopy(measurement0[pj]) end for pj in (length(measurement0)+1):p_num M_tp = [Vector{ComplexF64}(undef, dim) for i in 1:M_num] @@ -344,7 +344,7 @@ function initial_LinearComb!(measurement0, B_all, basis_num, M_num, p_num, rng) measurement0 = [measurement0[i] for i in 1:p_num] end for pj in 1:length(measurement0) - B_all[pj] = measurement0[pj] isa AbstractVector ? deepcopy(measurement0[pj]) : [[measurement0[pj][i,j] for j in 1:basis_num] for i in 1:M_num] + B_all[pj] = deepcopy(measurement0[pj]) end for pj in (length(measurement0)+1):p_num diff --git a/src/Parameterization/Lindblad/LindbladDynamics.jl b/src/Parameterization/Lindblad/LindbladDynamics.jl index 2f8a223..ed55328 100644 --- a/src/Parameterization/Lindblad/LindbladDynamics.jl +++ b/src/Parameterization/Lindblad/LindbladDynamics.jl @@ -90,7 +90,7 @@ function Htot( Hc::V, ctrl::Vector{R}, ) where {T<:AbstractArray,V<:AbstractVector, R<:Real} - H0 + ([ctrl[i] .* [Hc[i]] for i = 1:length(ctrl)] |> sum) + H0 + ([ctrl[i] * Hc[i] for i = 1:length(ctrl)] |> sum) end