From 97e72f54fa49c337db2938ffd973df2715b520a4 Mon Sep 17 00:00:00 2001 From: Boris MUZELLEC Date: Mon, 18 Nov 2024 16:23:30 +0100 Subject: [PATCH] refactor: throw ValueError instead of AssertionError in case of design with invalid type --- pydeseq2/dds.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pydeseq2/dds.py b/pydeseq2/dds.py index 2b662267..b1459d3b 100644 --- a/pydeseq2/dds.py +++ b/pydeseq2/dds.py @@ -271,10 +271,13 @@ def __init__( ) self.design = "~" + " + ".join(design_factors) - assert isinstance(self.design, (str, pd.DataFrame)) or isinstance( - self.design, str - ), "design must be a string representing a formulaic formula," - "or a pandas DataFrame." + if not ( + isinstance(self.design, (str, pd.DataFrame)) or isinstance(self.design, str) + ): + raise ValueError( + "design must be a string representing a formulaic formula," + "or a pandas DataFrame." + ) if isinstance(self.design, str): self.factor_storage, self.variable_to_factors, materializer_class = (