Skip to content

Commit c16fd25

Browse files
committed
code review changes
1 parent c018f27 commit c16fd25

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/cobra/core/reaction.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from collections import defaultdict
66
from copy import copy, deepcopy
77
from functools import partial
8-
from math import isinf, isclose
8+
from math import isclose, isinf
99
from operator import attrgetter
1010
from typing import (
1111
TYPE_CHECKING,
@@ -1451,7 +1451,11 @@ def check_mass_balance(self) -> Dict[str, float]:
14511451
for element, amount in metabolite.elements.items():
14521452
reaction_element_dict[element] += coefficient * amount
14531453
# filter out 0 values
1454-
return {k: v for k, v in reaction_element_dict.items() if not isclose(v, 0.0, abs_tol=1e-12)}
1454+
return {
1455+
k: v
1456+
for k, v in reaction_element_dict.items()
1457+
if not isclose(v, 0.0, abs_tol=config.tolerance)
1458+
}
14551459

14561460
@property
14571461
def compartments(self) -> Set:

tests/test_core/test_core_reaction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def test_mass_balance(model: Model) -> None:
336336
# Should be balanced even when coefficients are non-integer
337337
reaction_scaled = model.reactions.get_by_id("ATPS4r") * 1.3
338338
assert len(reaction_scaled.check_mass_balance()) == 0
339-
339+
340340

341341
def test_build_from_string(model: Model) -> None:
342342
"""Test reaction building from string evaluation."""

0 commit comments

Comments
 (0)