Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/readoperator.jl @ 830:21ab60cc0a5c operator_storage_array_of_table
Let parse_rational handle numbers and not just strings
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 12 Jan 2022 14:59:03 +0100 |
parents | ca182cbb8f49 |
children | 760c11e81fd4 |
comparison
equal
deleted
inserted
replaced
829:1de10f5b2008 | 830:21ab60cc0a5c |
---|---|
107 if !(toml["c"] isa Int) | 107 if !(toml["c"] isa Int) |
108 throw(ArgumentError("the center of a stencil must be specified as an integer.")) | 108 throw(ArgumentError("the center of a stencil must be specified as an integer.")) |
109 end | 109 end |
110 end | 110 end |
111 | 111 |
112 function parse_rational(str) | 112 function parse_rational(toml) |
113 expr = Meta.parse(replace(str, "/"=>"//")) | 113 if toml isa String |
114 return eval(:(Rational($expr))) | 114 expr = Meta.parse(replace(toml, "/"=>"//")) |
115 return eval(:(Rational($expr))) | |
116 else | |
117 return Rational(toml) | |
118 end | |
115 end | 119 end |
116 | 120 |
117 sbp_operators_path() = (@__DIR__) * "/operators/" | 121 sbp_operators_path() = (@__DIR__) * "/operators/" |