From 6d0d563d925c486204a4c3878dd5268625321c9c Mon Sep 17 00:00:00 2001 From: Luke Adams Date: Sun, 29 Dec 2024 16:39:02 -0700 Subject: [PATCH] test plasma_beta against plasmapy --- .gitignore | 1 + CondaPkg.toml | 3 +++ Project.toml | 4 +++- test/runtests.jl | 7 +++++-- 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 CondaPkg.toml diff --git a/.gitignore b/.gitignore index 5a16984..f2beb6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /Manifest.toml /docs/Manifest.toml /docs/build/ +.CondaPkg/ diff --git a/CondaPkg.toml b/CondaPkg.toml new file mode 100644 index 0000000..9a2d6cc --- /dev/null +++ b/CondaPkg.toml @@ -0,0 +1,3 @@ +[deps] +astropy = "" +plasmapy = "" diff --git a/Project.toml b/Project.toml index 3a1d6e1..01bc40c 100644 --- a/Project.toml +++ b/Project.toml @@ -12,6 +12,7 @@ UnitfulEquivalences = "da9c4bc3-91c8-4f02-8a40-6b990d2a7e0c" Aqua = "0.8" LinearAlgebra = "1.10" PermuteArgs = "1.2.1" +PythonCall = "0.9.23" Test = "1.10" Unitful = "1.0" UnitfulEquivalences = "0.2" @@ -20,7 +21,8 @@ julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Aqua", "LinearAlgebra", "Test"] +test = ["Aqua", "LinearAlgebra", "PythonCall", "Test"] diff --git a/test/runtests.jl b/test/runtests.jl index 6a37326..94c2f89 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,6 +3,10 @@ using Test using Aqua using Unitful using LinearAlgebra +using PythonCall + +units = pyimport("astropy.units") +formulary = pyimport("plasmapy.formulary") @testset "PlasmaFormulary.jl" begin @testset "Code quality (Aqua.jl)" begin @@ -35,7 +39,6 @@ using LinearAlgebra B = 0.1u"T" @test plasma_beta(T, n, B) == plasma_beta(n, B, PlasmaFormulary.temperature(T)) == plasma_beta(n, T, B) - units = pyimport("astropy.units") - formulary = pyimport("plasmapy.formulary") + @test pyconvert(Float64, pyfloat(formulary.lengths.Debye_length(10 * units.eV, 1e19 / units.m^3) / units.m)) ≈ ustrip(u"m", PlasmaFormulary.debye_length(1e19 * u"m^-3", 10 * u"eV")) rtol=1e-3 end end