Unverified Commit dac269e5 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil Committed by GitHub
Browse files

Merge pull request #141 from anandijain/aj/rational

rational mathval
parents b498d676 30f3426b
......@@ -57,6 +57,11 @@ function parse_math(ast::VPtr)::Math
return MathConst(get_string(ast, :ASTNode_getName))
elseif ast_is(ast, :ASTNode_isInteger)
return MathVal(ccall(sbml(:ASTNode_getInteger), Cint, (VPtr,), ast))
elseif ast_is(ast, :ASTNode_isRational)
return MathVal(
ccall(sbml(:ASTNode_getNumerator), Cint, (VPtr,), ast) //
ccall(sbml(:ASTNode_getDenominator), Cint, (VPtr,), ast),
elseif ast_is(ast, :ASTNode_isReal)
return MathVal(ccall(sbml(:ASTNode_getReal), Cdouble, (VPtr,), ast))
elseif ast_is(ast, :ASTNode_isFunction)
# Input files needed when running the tests will be downloaded here
......@@ -14,5 +14,14 @@
<reaction id="rationalTest" reversible="false" fast="false">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<cn type="rational">1<sep />5000</cn>
......@@ -128,7 +128,7 @@ end
@test m.units["time"] == 1 * u"s"
@test m.units["substance"] == 1 * u"mol"
m = readSBML(joinpath(@__DIR__, "data", "units.xml"))
m = readSBML(joinpath(@__DIR__, "data", "custom.xml"))
@test m.units["non_existent"] == 0.00314
@test m.units["no_dimensions"] == 20.0
......@@ -174,6 +174,11 @@ end
@test isequal(convert(Num, m.reactions["J29"].kinetic_math), 2.0 * S29 * S29b)
@testset "rationals in math" begin
m = readSBML(joinpath(@__DIR__, "data", "custom.xml"))
@test m.reactions["rationalTest"].kinetic_math.val == 1 // 5000
@testset "converters work and fail gracefully" begin
@test_logs (:error, r"^SBML reported error:") (:error, r"^SBML reported error:") @test_throws ErrorException readSBML(
joinpath(@__DIR__, "data", "sbml01289.xml"),
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