Skip to content

Commit

Permalink
- fix crash when ending eqn on species
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergmann committed May 19, 2022
1 parent a1e4d9a commit 49cf40a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion basico/model_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3711,7 +3711,7 @@ def _tokenize_eqn(eqn):
var = eqn[i + 1:pos]
var_is_species = True
i = pos + 1
c_0 = eqn[i]
c_0 = eqn[i] if i < num_chars else None
c_1 = eqn[i + 1] if i + 1 < num_chars else None

if c_0 == '_' and c_1 == '0':
Expand Down
3 changes: 2 additions & 1 deletion tests/test_model_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ def test_add_ode(self):
'd[CEX]/dt=(k_2 [E][PGME])/K_s -([E]/((k_4 [7-ADCA])/K_n +(k_5 [7-ADCA])/K_n +(k_6 [PGME])/K_si +k3))((k_2 [PGME])/K_s +(k_4b [CEX])/K_p )(k_3+(k_5 [7-ADCA])/K_n )')
basico.add_equation(
'[E]=([EA]_0 exp(-k_d t))/(1+([PGME])/K_s + ((k_2 [PGME])/(K_s ((k_4 [7-ADCA])/K_n +(k_5 [7-ADCA])/K_n +(k_6 [PGME])/K_si +k3) ))(1+([7-ADCA])/K_n +([PGME])/K_si )+([CEX])/K_p +([PG])/K_p2i )')

basico.add_equation('d[S1]/dt=-r_s1*w_1*[B]')
species = basico.get_species()
self.assertEqual(species.loc['PG'].type, 'ode')
self.assertEqual(species.loc['S1'].type, 'ode')
self.assertEqual(species.loc['PG'].expression, '[E] / ( Values[k_4] * [7-ADCA] / Values[K_n] + Values[k_5] * [7-ADCA] / Values[K_n] + Values[k_6] * [PGME] / Values[K_si] + Values[k3] ) * ( Values[k_2] * [PGME] / Values[K_s] + Values[k_4b] * [CEX] / Values[K_p] ) * ( Values[k_3] + Values[k_5] * [7-ADCA] / Values[K_n] + Values[k_6] * [PGME] / Values[K_si] )')
self.assertEqual(species.loc['E'].type, 'assignment')
self.assertEqual(species.loc['E'].expression, '[EA]_0 * exp ( - Values[k_d] * Time ) / ( 1 + [PGME] / Values[K_s] + Values[k_2] * [PGME] / ( Values[K_s] * ( Values[k_4] * [7-ADCA] / Values[K_n] + Values[k_5] * [7-ADCA] / Values[K_n] + Values[k_6] * [PGME] / Values[K_si] + Values[k3] ) ) * ( 1 + [7-ADCA] / Values[K_n] + [PGME] / Values[K_si] ) + [CEX] / Values[K_p] + [PG] / Values[K_p2i] )')
Expand Down

0 comments on commit 49cf40a

Please sign in to comment.