Skip to content

Commit

Permalink
Use full f.p. precision with BNG and Kappa (#490)
Browse files Browse the repository at this point in the history
Fixes: #443
  • Loading branch information
alubbock committed Jan 31, 2020
1 parent 681428b commit dccf662
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pysb/export/potterswheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ def export(self):
ic_values[self.model.get_species_index(ic.pattern)] = ic.value.value

# list of "dynamic variables"
pw_x = ["m = pwAddX(m, 's%d', %e);" % (i, ic_values[i])
pw_x = ["m = pwAddX(m, 's%d', %.17g);" % (i, ic_values[i])
for i in range(len(self.model.odes))]

# parameters
pw_k = ["m = pwAddK(m, '%s', %e);" % (p.name, p.value)
pw_k = ["m = pwAddK(m, '%s', %.17g);" % (p.name, p.value)
for p in self.model.parameters]

# equations (one for each dynamic variable)
Expand Down
2 changes: 1 addition & 1 deletion pysb/generator/bng.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def generate_parameters(self):
max_length = max(len(p.name) for p in
self.model.parameters | self.model.expressions)
for p in self.model.parameters:
self.__content += ((" %-" + str(max_length) + "s %e\n") %
self.__content += ((" %-" + str(max_length) + "s %.17g\n") %
(p.name, p.value))
for e in exprs:
self.__content += ((" %-" + str(max_length) + "s %s\n") %
Expand Down
2 changes: 1 addition & 1 deletion pysb/generator/kappa.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def generate_content(self):

def generate_parameters(self):
for p in self.model.parameters:
self.__content += "%%var: '%s' %e\n" % (p.name, p.value)
self.__content += "%%var: '%s' %.17g\n" % (p.name, p.value)
for e in self.model.expressions:
str_expr = str(expression_to_muparser(e))
self.__content += "%%var: '%s' %s\n" % (e.name, str_expr)
Expand Down
3 changes: 0 additions & 3 deletions pysb/tests/test_importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
'CaOscillate_Func': 1e-4,
'michment': 1e-8,
'motor': 1e-8,
'fceri_ji': 1e-4,
'test_paramname': 1e-4,
'tlmr': 1e-4,
'Repressilator': 1e-11,
}

Expand Down

0 comments on commit dccf662

Please sign in to comment.