未验证 提交 bed88234 编写于 作者: L lq 提交者: GitHub

Fix: Return type of validate.calculate_similarity (#628)

When an input is zero, it returns an Int, which results to `TypeError` in `compare_output`
上级 be144525
......@@ -69,9 +69,9 @@ def calculate_similarity(u, v, data_type=np.float64):
norm = u_norm * v_norm
if norm == 0:
if u_norm == 0 and v_norm == 0:
return 1
return data_type(1)
else:
return 0
return data_type(0)
else:
return np.dot(u, v) / norm
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册