mirror of
https://github.com/shouptech/humulus.git
synced 2026-02-03 17:19:42 +00:00
Fix divide by zero error
This commit is contained in:
parent
0324ead275
commit
b3d4db7551
1 changed files with 2 additions and 0 deletions
|
|
@ -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))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue