Mercurial > repos > public > sbplib_julia
changeset 828:ca182cbb8f49 operator_storage_array_of_table
Add a method to parse_stencil which allows controlling the element type
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 12 Jan 2022 08:39:48 +0100 |
parents | beae513ef8b3 |
children | 1de10f5b2008 |
files | src/SbpOperators/readoperator.jl test/SbpOperators/readoperator_test.jl |
diffstat | 2 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/SbpOperators/readoperator.jl Wed Jan 12 07:45:38 2022 +0100 +++ b/src/SbpOperators/readoperator.jl Wed Jan 12 08:39:48 2022 +0100 @@ -85,6 +85,8 @@ return Stencil(weights..., center = toml["c"]) end +parse_stencil(T, toml) = Stencil{T}(parse_stencil(toml)) + function check_stencil_toml(toml) if !(toml isa Dict || toml isa Vector{String}) throw(ArgumentError("the TOML for a stencil must be a vector of strings or a table."))
--- a/test/SbpOperators/readoperator_test.jl Wed Jan 12 07:45:38 2022 +0100 +++ b/test/SbpOperators/readoperator_test.jl Wed Jan 12 08:39:48 2022 +0100 @@ -111,5 +111,10 @@ Stencil(-4//43, 59//43, -110//43, 59//43, -4//43, 0//1; center=3), Stencil(-1//49, 0//1, 59//49, -118//49, 64//49, -4//49; center=4), ] + + + @test parse_stencil(Float64, TOML.parse(toml)["s1"]) == CenteredStencil(-1/12, 4/3, -5/2, 4/3, -1/12) + @test parse_stencil(Float64, TOML.parse(toml)["s2"]) == Stencil(2/1, -5/1, 4/1, -1/1, 0/1, 0/1; center=1) + @test parse_stencil(Float64, TOML.parse(toml)["s3"]) == Stencil(1/1, -2/1, 1/1, 0/1, 0/1, 0/1; center=2) end end