From: Michal Sojka Date: Thu, 2 Sep 2021 12:29:19 +0000 (+0200) Subject: Fix "ValueError: cannot convert float NaN to integer" X-Git-Url: http://rtime.felk.cvut.cz/gitweb/coffee/coffee-flask.git/commitdiff_plain Fix "ValueError: cannot convert float NaN to integer" --- diff --git a/app.py b/app.py index 0ad3298..473da29 100644 --- a/app.py +++ b/app.py @@ -200,7 +200,7 @@ def coffee_graph_flavors(): if "normalize" in matplotlib.pyplot.pie.__code__.co_varnames: # Matplotlib >= 3.3.0 ax.pie(counts, autopct=lambda p: '{:.0f}'.format(p * sum(counts)/100) if p != 0 else '', - normalize=True) + normalize=sum(counts) != 0) else: # Matplotlib < 3.3.0 ax.pie(counts, autopct=lambda p: '{:.0f}'.format(p * sum(counts)/100) if p != 0 else '')