Resolve the warnings of case test_search_binary_tanimoto_flat_index (#18918)

Signed-off-by: “nico” <Nico_1986@163.com>

Signed-off-by: “nico” <Nico_1986@163.com>
pull/18975/head
NicoYuan1986 2022-09-01 17:07:05 +08:00 committed by GitHub
parent 2570176fb2
commit 05c724ad6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -575,7 +575,12 @@ def hamming(x, y):
def tanimoto(x, y):
x = np.asarray(x, np.bool)
y = np.asarray(y, np.bool)
return -np.log2(np.double(np.bitwise_and(x, y).sum()) / np.double(np.bitwise_or(x, y).sum()))
res = np.double(np.bitwise_and(x, y).sum()) / np.double(np.bitwise_or(x, y).sum())
if res == 0:
value = 0
else:
value = -np.log2(res)
return value
def tanimoto_calc(x, y):