当前位置: 首页>>代码示例>>Python>>正文


Python MinHash.similarity方法代码示例

本文整理汇总了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
开发者ID:dib-lab,项目名称:sourmash,代码行数:19,代码来源:test__minhash.py

示例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
开发者ID:dib-lab,项目名称:sourmash,代码行数:10,代码来源:test__minhash.py


注:本文中的sourmash._minhash.MinHash.similarity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。