comparison src/SbpOperators/readoperator.jl @ 600:dd7056869294 refactor/toml_operator_format

Fix a couple of types
author Jonatan Werpers <jonatan@werpers.com>
date Sat, 05 Dec 2020 12:59:14 +0100
parents a21fe9b6e5b6
children b05f542b2e8f
comparison
equal deleted inserted replaced
599:a21fe9b6e5b6 600:dd7056869294
46 read_stencil(sbp_operators_path()*"standard_diagonal.toml", "order2", "D2", "inner_stencil") 46 read_stencil(sbp_operators_path()*"standard_diagonal.toml", "order2", "D2", "inner_stencil")
47 read_stencil(sbp_operators_path()*"standard_diagonal.toml", "order2", "d1", "closure"; center=1) 47 read_stencil(sbp_operators_path()*"standard_diagonal.toml", "order2", "d1", "closure"; center=1)
48 ``` 48 ```
49 """ 49 """
50 read_stencil(fn, path...; center=nothing) = get_stencil(TOML.parsefile(fn), path...; center=center) 50 read_stencil(fn, path...; center=nothing) = get_stencil(TOML.parsefile(fn), path...; center=center)
51 read_stencils(fn, path..., centers=nothing) = get_stencils(TOML.parsefile(fn), path...; centers=centers) 51 read_stencils(fn, path...; centers=nothing) = get_stencils(TOML.parsefile(fn), path...; centers=centers)
52 read_tuple(fn, path..., centers=nothing) = get_tuple(TOML.parsefile(fn), path...) 52 read_tuple(fn, path...) = get_tuple(TOML.parsefile(fn), path...)
53 53
54 get_stencil(parsed_toml, path...; center=nothing) = get_stencil(parsed_toml[path[1]], path[2:end]...; center=center) 54 get_stencil(parsed_toml, path...; center=nothing) = get_stencil(parsed_toml[path[1]], path[2:end]...; center=center)
55 function get_stencil(parsed_toml; center=nothing) 55 function get_stencil(parsed_toml; center=nothing)
56 @assert parsed_toml isa Vector{String} 56 @assert parsed_toml isa Vector{String}
57 stencil_weights = Float64.(parse_rational.(parsed_toml)) 57 stencil_weights = Float64.(parse_rational.(parsed_toml))
70 @assert parsed_toml isa Vector{Vector{String}} 70 @assert parsed_toml isa Vector{Vector{String}}
71 @assert length(centers) == length(parsed_toml) 71 @assert length(centers) == length(parsed_toml)
72 72
73 stencils = () 73 stencils = ()
74 for i ∈ 1:length(parsed_toml) 74 for i ∈ 1:length(parsed_toml)
75 stencil = get_stencil(parsed_toml[i]), center = centers[i] 75 stencil = get_stencil(parsed_toml[i], center = centers[i])
76 stencils = (stencils..., stencil) 76 stencils = (stencils..., stencil)
77 end 77 end
78 78
79 return stencils 79 return stencils
80 end 80 end