From e25df9c70987daa635b1f6fd14c38169b327aaad Mon Sep 17 00:00:00 2001 From: Haoyue Dai Date: Thu, 17 Oct 2024 17:40:06 -0400 Subject: [PATCH] fix the np.prod overflow issue in Chisq test --- causallearn/utils/cit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/causallearn/utils/cit.py b/causallearn/utils/cit.py index 8119dd72..09e5943e 100644 --- a/causallearn/utils/cit.py +++ b/causallearn/utils/cit.py @@ -288,7 +288,7 @@ def _Fill3DCountTableByUnique(dataSXY, cardSXY): def _Fill3DCountTable(dataSXY, cardSXY): # about the threshold 1e5, see a rough performance example at: # https://gist.github.com/MarkDana/e7d9663a26091585eb6882170108485e#file-count-unique-in-array-performance-md - if np.prod(cardSXY) < CONST_BINCOUNT_UNIQUE_THRESHOLD: return _Fill3DCountTableByBincount(dataSXY, cardSXY) + if 0 < np.prod(cardSXY) < CONST_BINCOUNT_UNIQUE_THRESHOLD: return _Fill3DCountTableByBincount(dataSXY, cardSXY) return _Fill3DCountTableByUnique(dataSXY, cardSXY) def _CalculatePValue(cTables, eTables):