From 2ecc5d34459d22ce6d37c192a27a522028b0ffdb Mon Sep 17 00:00:00 2001 From: Endre Moen Date: Fri, 3 Jan 2025 09:19:46 +0100 Subject: [PATCH] fix: handle residuals array is empty Signed-off-by: Endre Moen --- causallearn/search/ScoreBased/ExactSearch.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/causallearn/search/ScoreBased/ExactSearch.py b/causallearn/search/ScoreBased/ExactSearch.py index 8410c44c..596888a8 100644 --- a/causallearn/search/ScoreBased/ExactSearch.py +++ b/causallearn/search/ScoreBased/ExactSearch.py @@ -365,6 +365,8 @@ def bic_score_node(X, i, structure): b=X[:, i], rcond=None) bic = n * np.log(residual / n) + len(structure) * np.log(n) + if bic.size == 0: + return NEGINF # Return negative infinity if bic is empty return bic.item()