diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43e4761..45a5d19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: matrix: version: - '1' - - 'nightly' + - 'pre' os: - ubuntu-latest - macOS-latest @@ -30,7 +30,7 @@ jobs: - "2" steps: - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} arch: ${{ matrix.julia-arch }} @@ -55,7 +55,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: julia-actions/setup-julia@v2 with: version: '1' - run: | diff --git a/Project.toml b/Project.toml index ce67087..e795c30 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LaserTypes" uuid = "e07c0bfa-524c-4f35-a151-c3dd916fa2f0" authors = ["Sebastian Micluța-Câmpeanu ", "Petru-Vlad Toma "] -version = "0.1.9" +version = "0.2.0" [deps] AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f" @@ -31,8 +31,9 @@ julia = "1" [extras] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" +JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test", "SafeTestsets", "CSV"] +test = ["Test", "SafeTestsets", "CSV", "JET"] diff --git a/src/electricfield.jl b/src/electricfield.jl index 2b199c2..3e5a400 100644 --- a/src/electricfield.jl +++ b/src/electricfield.jl @@ -1,7 +1,5 @@ # # Electric Field -E(r, t, laser, symbol::Symbol) = E(r, t, laser, Val(symbol)) - function E(r, t, laser, v::Val{T}) where T @error "Got unsupported field type :$T\n Valid arguments are :real and :complex." end @@ -20,8 +18,8 @@ function E(r, t, laser, ::Val{:complex}) return inv_rotate(R, ElectricField) end -E(r, t, laser) = E(r, t, laser, :real) -E(r, t, laser, ::Val{:real}) = real(E(r, t, laser, :complex)) +E(r, t, laser) = E(r, t, laser, Val(:real)) +E(r, t, laser, ::Val{:real}) = real(E(r, t, laser, Val(:complex))) function E(x::SVector{4}, laser::AbstractLaser) inv_c = immutable_cache(laser, :inv_c) diff --git a/src/faraday.jl b/src/faraday.jl index cf2398f..b08517d 100644 --- a/src/faraday.jl +++ b/src/faraday.jl @@ -1,7 +1,5 @@ # # 4-Potential -EB(r, t, laser, symbol::Symbol) = EB(r, t, laser, Val(symbol)) - function EB(r, t, laser, v::Val{T}) where T @error "Got unsupported field type :$T\n Valid arguments are :real and :complex." end @@ -20,8 +18,8 @@ function EB(r, t, laser, ::Val{:complex}) return inv_rotate.((R,), E_B) end -EB(r, t, laser) = EB(r, t, laser, :real) -EB(r, t, laser, ::Val{:real}) = real.(EB(r, t, laser, :complex)) +EB(r, t, laser) = EB(r, t, laser, Val(:real)) +EB(r, t, laser, ::Val{:real}) = real.(EB(r, t, laser, Val(:complex))) function EB(r, laser) @assert length(r) == 3 "The laser is only defined in 3D" diff --git a/src/magneticfield.jl b/src/magneticfield.jl index 5a1e511..317977f 100644 --- a/src/magneticfield.jl +++ b/src/magneticfield.jl @@ -1,7 +1,5 @@ # # Magnetic Field -B(r, t, laser, symbol::Symbol) = B(r, t, laser, Val(symbol)) - function B(r, t, laser, v::Val{T}) where T @error "Got unsupported field type :$T\n Valid arguments are :real and :complex." end @@ -20,8 +18,8 @@ function B(r, t, laser, ::Val{:complex}) return inv_rotate(R, MagneticField) end -B(r, t, laser) = B(r, t, laser, :real) -B(r, t, laser, ::Val{:real}) = real(B(r, t, laser, :complex)) +B(r, t, laser) = B(r, t, laser, Val(:real)) +B(r, t, laser, ::Val{:real}) = real(B(r, t, laser, Val(:complex))) function B(x::SVector{4}, laser::AbstractLaser) inv_c = immutable_cache(laser, :inv_c) diff --git a/test/qa.jl b/test/qa.jl new file mode 100644 index 0000000..90f328e --- /dev/null +++ b/test/qa.jl @@ -0,0 +1,40 @@ +using LaserTypes, Test +using JET + +@testset "JET type stability tests" begin + @testset "$laser" for laser in [GaussLaser, LaguerreGaussLaser] + # Setup laser with atomic units (simplest for testing) + if laser == GaussLaser + lt_laser = setup_laser(GaussLaser, :atomic, profile=ConstantProfile()) + else + lt_laser = setup_laser(LaguerreGaussLaser, :atomic, profile=ConstantProfile(), p=1, m=1) + end + + r = [0.0, 0.0, 0.0] + t = 0.0 + + @testset "E field - Val(:real)" begin + @test_opt LaserTypes.E(r, t, lt_laser, Val(:real)) + end + + @testset "E field - Val(:complex)" begin + @test_opt LaserTypes.E(r, t, lt_laser, Val(:complex)) + end + + @testset "B field - Val(:real)" begin + @test_opt LaserTypes.B(r, t, lt_laser, Val(:real)) + end + + @testset "B field - Val(:complex)" begin + @test_opt LaserTypes.B(r, t, lt_laser, Val(:complex)) + end + + @testset "EB field - Val(:real)" begin + @test_opt LaserTypes.EB(r, t, lt_laser, Val(:real)) + end + + @testset "EB field - Val(:complex)" begin + @test_opt LaserTypes.EB(r, t, lt_laser, Val(:complex)) + end + end +end diff --git a/test/runtests.jl b/test/runtests.jl index d287c2f..51de03d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,4 +9,5 @@ using Test, SafeTestsets @safetestset "Fμν" begin include("faraday.jl") end @safetestset "Derived" begin include("derived.jl") end @safetestset "Show" begin include("show.jl") end + @safetestset "QA" begin include("qa.jl") end end