From adc9e5d0943c36120e0cfc3f7dbcf2f84877ce3c Mon Sep 17 00:00:00 2001 From: Sunny Sun <38218185+sunnyosun@users.noreply.github.com> Date: Thu, 21 Mar 2024 13:02:35 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20zero=20division=20eror=20i?= =?UTF-8?q?n=20inspect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamin_utils/_inspect.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lamin_utils/_inspect.py b/lamin_utils/_inspect.py index da1bae7..b01ea05 100644 --- a/lamin_utils/_inspect.py +++ b/lamin_utils/_inspect.py @@ -54,6 +54,15 @@ def _validate_stats(identifiers: Iterable, matches: "np.ndarray"): nonval = _unique_rm_empty(df_val.index[~df_val["__validated__"]]).tolist() n_unique = len(val) + len(nonval) + if n_unique == 0: + return InspectResult( + validated_df=df_val, + validated=val, + nonvalidated=nonval, + frac_validated=0, + n_empty=0, + n_unique=0, + ) n_empty = df_val.shape[0] - n_unique frac_nonval = round(len(nonval) / n_unique * 100, 1) frac_val = 100 - frac_nonval