From 540b33f234992fed73ad55b7e185fe55282f2559 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 12:32:58 +0000 Subject: [PATCH] refactor: remove assert statement from non-test files Usage of `assert` statement in application logic is discouraged. `assert` is removed with compiling to optimized byte code. Consider raising an exception instead. Ideally, `assert` statement should be used only in tests. --- hsf/factory.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hsf/factory.py b/hsf/factory.py index 737436f..5a2468f 100644 --- a/hsf/factory.py +++ b/hsf/factory.py @@ -189,9 +189,10 @@ def main(cfg: DictConfig) -> None: bs = cfg.hardware.engine_settings.batch_size multispectral = 2 if cfg.multispectrality.pattern else 1 - assert multispectral * ( + if multispectral * ( tta + 1 - ) % bs == 0, "test_time_num_aug+1 must be a multiple of batch_size for deepsparse" + ) % bs != 0: + raise AssertionError("test_time_num_aug+1 must be a multiple of batch_size for deepsparse") mris = load_from_config(cfg.files.path, cfg.files.pattern) _n = len(mris)