def _compare_reaction_defs(def1, def2): '''Returns True/False depending on whether reaction definitions are equal.''' return def1 is not None and def2 is not None and \ len(def1) == len(def2) and \ all([x[0] == y[0] and x[1] == y[1] and math_utils.isclose(x[2], y[2]) for x, y in zip(sorted(def1), sorted(def2))])
def test_isclose(self): '''Tests isclose method.''' self.assertTrue(math_utils.isclose(18.015054684, 18.015054684)) self.assertFalse(math_utils.isclose(18.015054684, 18.015054))
def _simplify_stoichs(stoichs): '''Attempts to simplify stoichs of 1.00000001 to 1.0.''' return [float(round(stoich)) if math_utils.isclose(stoich, round(stoich)) else stoich for stoich in stoichs]