From e0a99b10ee17e2505369088e05896a31aa2a681d Mon Sep 17 00:00:00 2001 From: thalassemia <67928790+thalassemia@users.noreply.github.com> Date: Fri, 19 Jan 2024 11:59:40 -0800 Subject: [PATCH] Remove asserts in JIT functions (breaks with pytest) --- .../ecoli/dataclasses/process/metabolism.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/reconstruction/ecoli/dataclasses/process/metabolism.py b/reconstruction/ecoli/dataclasses/process/metabolism.py index adcc9a95c..77880286d 100755 --- a/reconstruction/ecoli/dataclasses/process/metabolism.py +++ b/reconstruction/ecoli/dataclasses/process/metabolism.py @@ -2203,22 +2203,24 @@ def _is_transport_rxn(self, stoich): @njit def np_apply_along_axis(func1d, axis, arr): - assert arr.ndim == 2 - assert axis in [0, 1] - if axis == 0: - result = np.empty(arr.shape[1]) - for i in range(len(result)): - result[i] = func1d(arr[:, i]) - else: - result = np.empty(arr.shape[0]) - for i in range(len(result)): - result[i] = func1d(arr[i, :]) - return result + if arr.ndim != 2: + raise RuntimeError("Array must have 2 dimensions.") + if axis not in [0, 1]: + raise RuntimeError("Axis must be 0 or 1.") + if axis == 0: + result = np.empty(arr.shape[1]) + for i in range(len(result)): + result[i] = func1d(arr[:, i]) + else: + result = np.empty(arr.shape[0]) + for i in range(len(result)): + result[i] = func1d(arr[i, :]) + return result @njit def np_prod(array, axis): - return np_apply_along_axis(np.prod, axis, array) + return np_apply_along_axis(np.prod, axis, array) @njit