comparison src/SbpOperators/readoperator.jl @ 801:04e549669b10 operator_storage_array_of_table

Consider feedback ;)
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 25 Jul 2021 16:12:24 +0200
parents 26bf5b2b3e32
children b874c26ea7d1
comparison
equal deleted inserted replaced
800:f91495f23604 801:04e549669b10
76 76
77 weights = Float64.(parse_rational.(toml["s"])) 77 weights = Float64.(parse_rational.(toml["s"]))
78 return Stencil(weights..., center = toml["c"]) 78 return Stencil(weights..., center = toml["c"])
79 end 79 end
80 80
81 # TBD Vidar:
82 # I suggest the following restructure, for a clearer control flow.
83 # function check_stencil_toml(toml)
84 # if toml isa Vector{String}
85 # return
86 # end
87 #
88 # if toml isa Dict
89 # if !(haskey(toml, "s") && haskey(toml, "c"))
90 # throw(ArgumentError("the table form of a stencil must have fields `s` and `c`."))
91 # end
92 #
93 # if !(toml["s"] isa Vector{String})
94 # throw(ArgumentError("a stencil must be specified as a vector of strings."))
95 # end
96 #
97 # if !(toml["c"] isa Int)
98 # throw(ArgumentError("the center of a stencil must be specified as an integer."))
99 # end
100 # return
101 # end
102 # throw(ArgumentError("the TOML for a stencil must be a vector of strings or a table."))
103 # end
104 function check_stencil_toml(toml) 81 function check_stencil_toml(toml)
105 if !(toml isa Dict || toml isa Vector{String}) 82 if !(toml isa Dict || toml isa Vector{String})
106 throw(ArgumentError("the TOML for a stencil must be a vector of strings or a table.")) 83 throw(ArgumentError("the TOML for a stencil must be a vector of strings or a table."))
107 end 84 end
108 85