-
Notifications
You must be signed in to change notification settings - Fork 70
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
Extend function support in BNGL import and pysb export #518
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #518 +/- ##
=======================================
Coverage 80.27% 80.27%
=======================================
Files 101 101
Lines 10664 10668 +4
=======================================
+ Hits 8560 8564 +4
Misses 2104 2104
Continue to review full report at Codecov.
|
@@ -42,7 +70,7 @@ def __init__(self, filename, force=False, cleanup=True): | |||
|
|||
self.model.name = os.path.splitext(os.path.basename(filename))[0] | |||
self._force = force | |||
self._model_env = {} | |||
self._model_env = BNGL_FUNCTIONS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is enumerating the functions like this necessary? It seems to work on current master
branch already. Here's a test program:
from pysb.importers.bngl import model_from_bngl
import tempfile
bngl_test = """
begin seed species
A 100
B 100
end seed species
begin reaction rules
A() + B() <-> C() 0.01, 1
end reaction rules
# not used in model, only for import tests
begin functions
f1() = exp(10)
f2() = atanh(10)
f3() = sqrt(log2(50))
end functions
"""
with tempfile.NamedTemporaryFile('w', suffix='.bngl', encoding='utf8') as tf:
tf.write(bngl_test)
tf.flush()
model = model_from_bngl(tf.name)
print(model)
for expr in model.expressions:
print(f'{expr.name}: {expr.expr.evalf()}')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a while since I wrote that code, so I am not sure. I am surprised that log2 actually works, since this definitely used to require the mapping. This might be due to recent changes by @jmuhlich or sympy added log10
and log2
functions function.
Codecov Report
@@ Coverage Diff @@
## master #518 +/- ##
==========================================
+ Coverage 80.16% 80.25% +0.08%
==========================================
Files 100 101 +1
Lines 10650 10717 +67
==========================================
+ Hits 8538 8601 +63
- Misses 2112 2116 +4
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
This adds support of all BNGL supported functions during import of BNGL models. For export of pysb models to file, all supported functions are always imported from sympy such that model evaluation does not fail in case any of these functions is used in an
pysb.Expression
.