Commit 29952ce0 authored by Mosè Giordano's avatar Mosè Giordano
Browse files

Fix for dimensionless units

parent 4d51159f
......@@ -177,7 +177,7 @@ function extractModel(mdl::VPtr)::SBML.Model
end
# parse out the unit definitions
units = Dict{String,Quantity}()
units = Dict{String,Number}()
for i = 1:ccall(sbml(:Model_getNumUnitDefinitions), Cuint, (VPtr,), mdl)
ud = ccall(sbml(:Model_getUnitDefinition), VPtr, (VPtr, Cuint), mdl, i - 1)
id = get_string(ud, :UnitDefinition_getId)
......
......@@ -160,7 +160,7 @@ objects.
"""
struct Model
parameters::Dict{String,Float64}
units::Dict{String,Quantity}
units::Dict{String,Number}
compartments::Dict{String,Compartment}
species::Dict{String,Species}
reactions::Dict{String,Reaction}
......
<?xml version='1.0' encoding='UTF-8'?>
<sbml xmlns:fbc="http://www.sbml.org/sbml/level3/version1/fbc/version2" xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1" sboTerm="SBO:0000624" fbc:required="false">
<model fbc:strict="true" id="e_coli_core">
<listOfUnitDefinitions>
<unitDefinition id="non_existent">
<listOfUnits>
<unit kind="blahblah" scale="-3" multiplier="3.14" exponent="1"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="no_dimensions">
<listOfUnits>
<unit kind="dimensionless" scale="3" multiplier="0.001" exponent="1"/>
<unit kind="item" scale="1" multiplier="2" exponent="1"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
</model>
</sbml>
......@@ -98,6 +98,10 @@ end
@test m.units["volume"] == 1 * u"L"
@test m.units["time"] == 1 * u"s"
@test m.units["substance"] == 1 * u"mol"
m = readSBML(joinpath(@__DIR__, "data", "units.xml"))
@test m.units["non_existent"] == 0.00314
@test m.units["no_dimensions"] == 20.0
end
@testset "Initial amounts and concentrations" begin
......
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