本文整理匯總了Python中sourmash._minhash.MinHash.similarity方法的典型用法代碼示例。如果您正苦於以下問題:Python MinHash.similarity方法的具體用法?Python MinHash.similarity怎麽用?Python MinHash.similarity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sourmash._minhash.MinHash
的用法示例。
在下文中一共展示了MinHash.similarity方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_minhash_abund_merge_flat
# 需要導入模塊: from sourmash._minhash import MinHash [as 別名]
# 或者: from sourmash._minhash.MinHash import similarity [as 別名]
def test_minhash_abund_merge_flat():
# this targets a segfault caused by trying to compute similarity
# of a signature with abundance and a signature without abundance.
# the correct behavior for now is to calculate simple Jaccard,
# i.e. 'flatten' both of them.
a = MinHash(0, 10, track_abundance=True, max_hash=5000)
b = MinHash(0, 10, max_hash=5000)
for i in range(0, 10, 2):
a.add_hash(i)
for j in range(0, 10, 3):
b.add_hash(i)
# these crashed, previously.
assert a.similarity(b) == 0.2
assert b.similarity(a) == 0.2
示例2: test_div_zero
# 需要導入模塊: from sourmash._minhash import MinHash [as 別名]
# 或者: from sourmash._minhash.MinHash import similarity [as 別名]
def test_div_zero(track_abundance):
# verify that empty MHs do not yield divide by zero errors for similarity
mh = MinHash(1, 4, track_abundance=track_abundance)
mh2 = mh.copy_and_clear()
mh.add_sequence('ATGC')
assert mh.similarity(mh2) == 0
assert mh2.similarity(mh) == 0