1
0
Fork 0
mirror of https://github.com/shouptech/humulus.git synced 2026-02-03 16:09:44 +00:00

Fix divide by zero error

This commit is contained in:
Emma 2019-07-05 09:20:24 -06:00
parent 0324ead275
commit b3d4db7551

View file

@ -83,6 +83,8 @@ def recipe_ibu_ratio(recipe):
"""Return a recipe's IBU ratio""" """Return a recipe's IBU ratio"""
if 'fermentables' not in recipe or 'hops' not in recipe: if 'fermentables' not in recipe or 'hops' not in recipe:
return '0' return '0'
if len(recipe['fermentables']) == 0:
return '0' # Otherwise a divide by zero error will occur
og = float(recipe_og(recipe)) og = float(recipe_og(recipe))
ibu = float(recipe_ibu(recipe)) ibu = float(recipe_ibu(recipe))
return '{:.2f}'.format(round(0.001 * ibu / (og - 1), 2)) return '{:.2f}'.format(round(0.001 * ibu / (og - 1), 2))