def test_uneven_out_bounds(): x = np.array([2., 1., .5, 1., 1., 1., .5, 1.]).T path = os.path.join(BASE_DIR, 'test_xmls/rxns_rev_ob_test.xml') rrr = ReactionSet(path) try: rrr.reaction_rates(x, 210) except ValueError as err: assert (type(err) == ValueError) try: rrr.reaction_rates(x, 3020) except ValueError as err: assert (type(err) == ValueError)
def test_reaction_rates_rev(): x = np.array([2., 1., .5, 1., 1., 1., .5, 1.]).T path = os.path.join(BASE_DIR, 'test_xmls/rxns_rev.xml') rrr = ReactionSet(path) assert(np.isclose(rrr.progress_rates(x,750), [-3.43641832e+16, -5.88589924e+11, 1.36640381e+12, \ -5.51788793e+14, 1.45474612e+13, 6.75189291e+13, \ 1.62500000e+13, 7.82443985e+12, 2.55000887e+13, \ 2.69382512e+13, 2.84197199e+12]).all()) assert(np.isclose(rrr.reaction_rates(x,750),[3.42304562795e16,-3.38308977852e16,-3.52979102957e+16, \ 4.07078984572e+13,5.86479724945e+14,3.44028050967e+16, \ -7.63606068937e+13,-5.52803118677e+13]).all())
def test_reaction_rates_rev_high(): x = np.array([2., 1., .5, 1., 1., 1., .5, 1.]).T path = os.path.join(BASE_DIR, 'test_xmls/rxns_rev.xml') rrr = ReactionSet(path) try: rrr.progress_rates(x, 3501) except ValueError as err: assert (type(err) == ValueError) try: rrr.reaction_rates(x, 10000) except ValueError as err: assert (type(err) == ValueError) try: rrr.reaction_rates(x, float('inf')) except FloatingPointError as err: assert (type(err) == FloatingPointError) # bonus test try: rrr.reaction_rates('12,34,5,2,1', 1300) except ValueError as err: assert (type(err) == ValueError) try: rrr.progress_rates('12,34,5,2,1', 1300) except ValueError as err: assert (type(err) == ValueError)
def test_reaction_rates_rev_low(): x = np.array([2., 1., .5, 1., 1., 1., .5, 1.]).T path = os.path.join(BASE_DIR, 'test_xmls/rxns_rev.xml') rrr = ReactionSet(path) try: rrr.progress_rates(x, 190) except ValueError as err: assert (type(err) == ValueError) try: rrr.reaction_rates(x, 190) except ValueError as err: assert (type(err) == ValueError) try: rrr.reaction_rates(x, 10) except FloatingPointError as err: assert (type(err) == FloatingPointError) # bonus test try: rrr.reaction_rates(x, 'f') except ValueError as err: assert (type(err) == ValueError) try: rrr.progress_rates(x, 'f') except ValueError as err: assert (type(err) == ValueError)
def test_reaction_rates(): x = np.array([[1.], [2.], [1.]]) path = os.path.join(BASE_DIR, 'test_xmls/reaction_rate_1.xml') rrr = ReactionSet(path) assert (np.array_equal(rrr.progress_rates(x, 10), [40.0, 10.0])) assert (np.array_equal(rrr.reaction_rates(x, 10), [-60.0, -70.0, 70.0]))