Commit b276ed48 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil
Browse files

fix argument order and count for piecewise function

Fixes #112
parent 00b48fb4
...@@ -45,7 +45,7 @@ const default_symbolics_mapping = Dict{String,Any}( ...@@ -45,7 +45,7 @@ const default_symbolics_mapping = Dict{String,Any}(
"ln" => :log, "ln" => :log,
"log" => :sbmlLog, "log" => :sbmlLog,
"lt" => :<, "lt" => :<,
"piecewise" => :(Core.ifelse), "piecewise" => :(sbmlPiecewise),
"power" => :^, "power" => :^,
"root" => :sbmlRoot, "root" => :sbmlRoot,
"sech" => :sech, "sech" => :sech,
...@@ -56,6 +56,17 @@ const default_symbolics_mapping = Dict{String,Any}( ...@@ -56,6 +56,17 @@ const default_symbolics_mapping = Dict{String,Any}(
"tan" => :tan, "tan" => :tan,
) )
function sbmlPiecewise(args...)
if length(args) == 1
args[1]
elseif length(args) >= 3
Core.ifelse(args[2], args[1], sbmlPiecewise(args[3:end]...))
else
throw(AssertionError("malformed piecewise SBML function"))
end
end
sbmlLog(x) = log(x, 10) sbmlLog(x) = log(x, 10)
sbmlLog(base, x) = log(base, x) sbmlLog(base, x) = log(base, x)
......
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
test = SBML.MathApply( test = SBML.MathApply(
"piecewise", "piecewise",
SBML.Math[ SBML.Math[
SBML.MathApply("lt", SBML.Math[SBML.MathVal(1), SBML.MathVal(0)]),
SBML.MathVal(123), SBML.MathVal(123),
SBML.MathApply("lt", SBML.Math[SBML.MathVal(1), SBML.MathVal(0)]),
SBML.MathVal(456), SBML.MathVal(456),
], ],
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment