From 31b1480cb6dcfa8fd02c1fe8abf315943feea3e7 Mon Sep 17 00:00:00 2001 From: Redmar Date: Thu, 11 Jun 2020 14:57:19 +0200 Subject: [PATCH] Fix ZeroDivisionError When there are no fusion events at all, FuMa crashes because the progress is calculated relative to the total number of fusion events. This fixes issue #43 --- fuma/ComparisonTriangle.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fuma/ComparisonTriangle.py b/fuma/ComparisonTriangle.py index c491234..0b2c8a1 100644 --- a/fuma/ComparisonTriangle.py +++ b/fuma/ComparisonTriangle.py @@ -147,7 +147,10 @@ def prune_duplicates(self,merged_fusions): def log_progress(self,n_total, passed, previous_percentage): # Print percentage - doesn't entirely fit yet - percentage = 100.0 * (float(passed) / float(n_total)) + try: + percentage = 100.0 * (float(passed) / float(n_total)) + except ZeroDivisionError: + percentage = 100.0 if percentage >= previous_percentage + 5.0 or passed == n_total:# Repport each 5% self.logger.debug(str(round(percentage,1))+"% completed") previous_percentage = percentage