From ad372e066aa6231bee355ed7d6fcf54a315c229a Mon Sep 17 00:00:00 2001 From: Jorge Carrasco Date: Tue, 27 Oct 2020 09:36:54 +0100 Subject: [PATCH] fix: guard against divison by 0 (#263) --- cameo/flux_analysis/analysis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cameo/flux_analysis/analysis.py b/cameo/flux_analysis/analysis.py index c84902d85..5502aa8c0 100644 --- a/cameo/flux_analysis/analysis.py +++ b/cameo/flux_analysis/analysis.py @@ -637,9 +637,9 @@ def mass_yield(self): try: source, source_flux = single_flux(self.source, consumption=True) product, product_flux = single_flux(self.product_reaction, consumption=False) - except ValueError: + mol_prod_mol_src = product_flux / source_flux + except (ValueError, ZeroDivisionError): return numpy.nan - mol_prod_mol_src = product_flux / source_flux return (mol_prod_mol_src * product.formula_weight) / source.formula_weight def __call__(self, points):