changeset 800:f91495f23604 operator_storage_array_of_table

Merge
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 25 Jul 2021 15:39:29 +0200
parents 24df68453890 (current diff) 26bf5b2b3e32 (diff)
children 04e549669b10
files src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl
diffstat 1 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/readoperator.jl	Sun Jul 25 15:31:06 2021 +0200
+++ b/src/SbpOperators/readoperator.jl	Sun Jul 25 15:39:29 2021 +0200
@@ -9,7 +9,7 @@
 # The read_stencil_set and get_stencil_set functions return the freshly parsed
 # toml. The generic code in these functions can't be expected to know anyhting
 # about how to read different stencil sets as they may contain many different
-# kinds of stecils. We should how ever add read_ and get_ functions for all
+# kinds of stencils. We should how ever add read_ and get_ functions for all
 # the types of stencils we know about.
 #
 # After getting a stencil set the user can use parse functions to parse what
@@ -23,6 +23,8 @@
 
 # TODO: Control type for the stencil
 # TODO: Think about naming and terminology around freshly parsed TOML.
+# Vidar: What about get_stencil instead of parse_stencil for an already parsed
+# toml. It matches get_stencil_set.
 
 """
     read_stencil_set(fn; filters)
@@ -76,9 +78,32 @@
     return Stencil(weights..., center = toml["c"])
 end
 
+# TBD Vidar:
+# I suggest the following restructure, for a clearer control flow.
+# function check_stencil_toml(toml)
+#     if toml isa Vector{String}
+#         return
+#     end
+#
+#     if toml isa Dict
+#       if !(haskey(toml, "s") && haskey(toml, "c"))
+#             throw(ArgumentError("the table form of a stencil must have fields `s` and `c`."))
+#       end
+#
+#       if !(toml["s"] isa Vector{String})
+#           throw(ArgumentError("a stencil must be specified as a vector of strings."))
+#       end
+#
+#       if !(toml["c"] isa Int)
+#             throw(ArgumentError("the center of a stencil must be specified as an integer."))
+#       end
+#       return
+#     end
+#     throw(ArgumentError("the TOML for a stencil must be a vector of strings or a table."))
+# end
 function check_stencil_toml(toml)
     if !(toml isa Dict || toml isa Vector{String})
-        throw(ArgumentError("the TOML for a stecil must be a vector of strings or a table."))
+        throw(ArgumentError("the TOML for a stencil must be a vector of strings or a table."))
     end
 
     if toml isa Vector{String}