Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/readoperator.jl @ 792:26bf5b2b3e32 operator_storage_array_of_table
Comment on naming and add suggestion for restructure of check_stencil_toml
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 22 Jul 2021 14:26:34 +0200 |
parents | 7669c1e3a9a4 |
children | 04e549669b10 |
comparison
equal
deleted
inserted
replaced
791:7669c1e3a9a4 | 792:26bf5b2b3e32 |
---|---|
21 # maybe there is a better name than parse? | 21 # maybe there is a better name than parse? |
22 # Would be nice to be able to control the type in the stencil | 22 # Would be nice to be able to control the type in the stencil |
23 | 23 |
24 # TODO: Control type for the stencil | 24 # TODO: Control type for the stencil |
25 # TODO: Think about naming and terminology around freshly parsed TOML. | 25 # TODO: Think about naming and terminology around freshly parsed TOML. |
26 # Vidar: What about get_stencil instead of parse_stencil for an already parsed | |
27 # toml. It matches get_stencil_set. | |
26 | 28 |
27 """ | 29 """ |
28 read_stencil_set(fn; filters) | 30 read_stencil_set(fn; filters) |
29 | 31 |
30 Picks out a stencil set from the given toml file based on some filters. | 32 Picks out a stencil set from the given toml file based on some filters. |
74 | 76 |
75 weights = Float64.(parse_rational.(toml["s"])) | 77 weights = Float64.(parse_rational.(toml["s"])) |
76 return Stencil(weights..., center = toml["c"]) | 78 return Stencil(weights..., center = toml["c"]) |
77 end | 79 end |
78 | 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 | |
79 function check_stencil_toml(toml) | 104 function check_stencil_toml(toml) |
80 if !(toml isa Dict || toml isa Vector{String}) | 105 if !(toml isa Dict || toml isa Vector{String}) |
81 throw(ArgumentError("the TOML for a stencil must be a vector of strings or a table.")) | 106 throw(ArgumentError("the TOML for a stencil must be a vector of strings or a table.")) |
82 end | 107 end |
83 | 108 |