Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit validation with distrib uniform not working #365

Open
matthiaskoenig opened this issue Jan 31, 2024 · 4 comments
Open

Unit validation with distrib uniform not working #365

matthiaskoenig opened this issue Jan 31, 2024 · 4 comments

Comments

@matthiaskoenig
Copy link

matthiaskoenig commented Jan 31, 2024

Hi all,
I have an SBML model with an initial assignment from a uniform distribution (model attached).
spt_random.zip
Despite having set the units on the distributions I get a unit validation warning.
It seems like the unit validation does not work with the distributions.

Here the basic structure. An initial assignment from a uniform(0 dimensionless, 1 dimensionless) to a parameter which is dimensionless. I.e. the distribution and the parameter are compatible, but still get the warning below.

<listOfParameters>
  <parameter id="protein_random" value="0.5" units="dimensionless" constant="true"/>
</listOfParameters>
<listOfInitialAssignments>
  <initialAssignment symbol="protein_random">
    <math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:sbml="http://www.sbml.org/sbml/level3/version2/core">
      <apply>
        <csymbol encoding="text" definitionURL="http://www.sbml.org/sbml/symbols/distrib/uniform"> uniform </csymbol>
        <cn sbml:units="dimensionless" type="integer"> 0 </cn>
        <cn sbml:units="dimensionless" type="integer"> 1 </cn>
      </apply>
    </math>
  </initialAssignment>
</listOfInitialAssignments>
WARNING  E0: SBML unit consistency (core, L91, code)                                                                                                                                                          validation.py:186
         [Warning] Missing unit declarations on parameters or literal numbers in expression                                                                                                                                    
         In situations where a mathematical expression contains literal numbers or parameters whose units have not been declared, it is not possible to verify accurately the consistency of the units in the                  
         expression.                                                                                                                                                                                                           
          The units of the <initialAssignment> <math> expression 'uniform(0, 1)' cannot be fully checked. Unit consistency reported as either no errors or further unit errors related to this object may not                  
         be accurate.      

Probably similar things happen with the other csymbol distributions.

Best Matthias

@fbergmann
Copy link
Member

looks like unit validation cannot know what the result of a function defined in the distrib package is. I am not aware of any plugin system in libSBML that allows packages to extend unit validation. Will have to discuss with @skeating

@matthiaskoenig
Copy link
Author

Thanks.
I tried the following 'uniform(0, 1) dimensionless', i.e. annotating the unit of the csymbol similar to constants in math expressions (e.g. 1 dimensionless`). Not sure if something like this could work to communicate the unit.

@fbergmann
Copy link
Member

it feels like the proper thing to do would be to have the distrib plugin provide information about the csymbols and the unit input/output relationship. adding dimensionless like in your example would prove troublesome in more involved expressions, potentially.

@matthiaskoenig
Copy link
Author

Hi all,
is there some simple solution to support unit validation for the distributions? I have some models using the distrib features with units and these errors make it hard to unit validate the models.
Best Matthias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants