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

Infer units for numeric literals #131

Open
artgoldberg opened this issue Dec 19, 2019 · 0 comments
Open

Infer units for numeric literals #131

artgoldberg opened this issue Dec 19, 2019 · 0 comments

Comments

@artgoldberg
Copy link
Contributor

Because numeric literals are 'dimensionless', expressions cannot use them as terms that must have dimensions. E.g, consider this rate law: (k1 * P[c] * (P[c] - 1)) / 2.

Validating the model that contains it generates this error:

ValueError: The model cannot be loaded because it fails to validate:
  Parameter:
    1:
      'id':
        Value '1' does not match pattern: ^(?!(^|\b)(\d+(\.\d*)?(\b|$))|(\.\d+$)|(0[x][0-9a-f]+(\b|$))|([0-9]+e[0-9]+(\b|$)))[a-z0-9_]+$
  RateLaw:
    Dimerization-forward:
      'units':
        Exception: cannot eval expression '(k1 * P[c] * (P[c] - 1)) / 2' in RateLawExpression; Cannot convert from 'molecule' ([substance]) to 'dimensionless' (dimensionless)

I suggest that if the units of a numeric literal can be unambiguously determined, then they should be determined.

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

No branches or pull requests

1 participant