From 39b2388ec035698a0eb5a2f424ac6fc3e16d4227 Mon Sep 17 00:00:00 2001 From: Michael Simpson Date: Mon, 14 Apr 2025 11:28:19 -0400 Subject: [PATCH] Fix Type Error in Conditional Logic The old logic was asking for `D`'s shape, which indicated that it should be a NumPy array. However, if you check the truth value of a NumPy array, you get an error. The code is checking for the existence of `D`. The most direct way to handle that is to make sure that it isn't `None`. --- faiss/python/class_wrappers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faiss/python/class_wrappers.py b/faiss/python/class_wrappers.py index 71756f5522..2491aa8914 100644 --- a/faiss/python/class_wrappers.py +++ b/faiss/python/class_wrappers.py @@ -1038,7 +1038,7 @@ def replacement_vt_train(self, x): def handle_AutoTuneCriterion(the_class): def replacement_set_groundtruth(self, D, I): - if D: + if D is not None: assert I.shape == D.shape self.nq, self.gt_nnn = I.shape self.set_groundtruth_c(