Skip to content

Commit c91d6fe

Browse files
providing more information about failed reactions
1 parent bd47075 commit c91d6fe

3 files changed

Lines changed: 45 additions & 2 deletions

File tree

arrow/obsidian.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ evolve_result evolve(Info *info, double duration, int64_t *state, double *rates)
182182
printf("failed simulation: total propensity is NaN\n");
183183
int max_reaction = 0;
184184
for (reaction = 0; reaction < reactions_count; reaction++) {
185-
if (propensities[reaction] > propensities[max_reaction]) {
185+
printf("reaction %lld is %f\n", reaction, propensities[reaction]);
186+
if (isnan(propensities[reaction]) || propensities[reaction] > propensities[max_reaction]) {
186187
max_reaction = reaction;
187188
}
188189
}

arrow/test/test_arrow.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,45 @@ def test_pickle():
234234

235235
print('arrow object pickled is {} bytes'.format(len(pickled_arrow)))
236236

237+
def test_flagella():
238+
stoichiometry = np.array(
239+
[[ 0, 0, 0, 0, 0, -4, -2, 0, 0, 0, 0,
240+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
241+
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
242+
0, 0, 0],
243+
[ -26, -34, -1, 0, 0, 0, 0, 0, 0, 0, 0,
244+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
245+
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
246+
0, 0, 0],
247+
[ 0, 0, 0, -1, -1, 0, 0, -1, -1, -1, -1,
248+
-1, -6, 0, 0, 0, 0, 0, 0, 0, 0, 0,
249+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
250+
1, 0, 0],
251+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
252+
0, 0, -12, 0, 0, 0, 0, 0, 0, 0, 0,
253+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
254+
-1, 1, 0],
255+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
256+
0, 0, 0, -2, -1, -1, -1, -1, -1, -1, -1,
257+
-1, -1, -1, 0, 0, 0, 0, 0, 0, -1, 0,
258+
0, 0, 1],
259+
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
260+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
261+
0, 0, 0, -1, -1, -1, -5, -120, 0, 0, 1,
262+
0, -1, -1]])
263+
264+
substrate = np.array([
265+
21, 1369, 69, 4, 1, 1674, 0, 48, 53, 49, 61, 7,
266+
3, 28, 151, 0, 26, 20, 3, 3, 9, 16, 7, 26,
267+
280, 26, 64, 67, 310, 13559, 208, 16, 22, 0, 17, 0], np.int64)
268+
269+
rates = np.array([1.e-05, 1.e-05, 1.e-05, 1.e-05, 1.e-05, 1.e-05])
270+
271+
arrow = StochasticSystem(stoichiometry)
272+
result = arrow.evolve(1.0, substrate, rates)
273+
274+
print('flagella result: {}'.format(result))
275+
237276

238277
def main(args):
239278
systems = (
@@ -254,6 +293,8 @@ def main(args):
254293
test_compare_runtime()
255294
elif args.pickle:
256295
test_pickle()
296+
elif args.flagella:
297+
test_flagella()
257298
else:
258299
for system in systems:
259300
system()
@@ -300,5 +341,6 @@ def main(args):
300341
parser.add_argument('--memory', action='store_true')
301342
parser.add_argument('--time', action='store_true')
302343
parser.add_argument('--pickle', action='store_true')
344+
parser.add_argument('--flagella', action='store_true')
303345

304346
main(parser.parse_args())

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
setup(
4141
name='stochastic-arrow',
42-
version='0.4.2',
42+
version='0.4.3',
4343
packages=['arrow'],
4444
author='Ryan Spangler, John Mason, Jerry Morrison',
4545
author_email='spanglry@stanford.edu',

0 commit comments

Comments
 (0)