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


Python DissimilarityMatrix.from_iterable方法代码示例

本文整理汇总了Python中skbio.stats.distance.DissimilarityMatrix.from_iterable方法的典型用法代码示例。如果您正苦于以下问题:Python DissimilarityMatrix.from_iterable方法的具体用法?Python DissimilarityMatrix.from_iterable怎么用?Python DissimilarityMatrix.from_iterable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在skbio.stats.distance.DissimilarityMatrix的用法示例。


在下文中一共展示了DissimilarityMatrix.from_iterable方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_from_iterable_with_key_and_keys

# 需要导入模块: from skbio.stats.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.stats.distance.DissimilarityMatrix import from_iterable [as 别名]
 def test_from_iterable_with_key_and_keys(self):
     iterable = (x for x in range(4))
     with self.assertRaises(ValueError):
         DissimilarityMatrix.from_iterable(iterable,
                                           lambda a, b: abs(b - a),
                                           key=str,
                                           keys=['1', '2', '3', '4'])
开发者ID:jakereps,项目名称:scikit-bio,代码行数:9,代码来源:test_base.py

示例2: test_from_iterable_asymmetric_data

# 需要导入模块: from skbio.stats.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.stats.distance.DissimilarityMatrix import from_iterable [as 别名]
    def test_from_iterable_asymmetric_data(self):
        iterable = (x for x in range(4))

        exp = DissimilarityMatrix([[0, 1, 2, 3],
                                   [-1, 0, 1, 2],
                                   [-2, -1, 0, 1],
                                   [-3, -2, -1, 0]])
        res = DissimilarityMatrix.from_iterable(iterable, lambda a, b: b - a)
        self.assertEqual(res, exp)
开发者ID:jakereps,项目名称:scikit-bio,代码行数:11,代码来源:test_base.py

示例3: test_from_iterable_non_hollow_data

# 需要导入模块: from skbio.stats.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.stats.distance.DissimilarityMatrix import from_iterable [as 别名]
    def test_from_iterable_non_hollow_data(self):
        iterable = (x for x in range(4))

        exp = DissimilarityMatrix([[1, 1, 1, 1],
                                   [1, 1, 1, 1],
                                   [1, 1, 1, 1],
                                   [1, 1, 1, 1]])
        res = DissimilarityMatrix.from_iterable(iterable, lambda a, b: 1)
        self.assertEqual(res, exp)
开发者ID:jakereps,项目名称:scikit-bio,代码行数:11,代码来源:test_base.py

示例4: test_from_iterable_no_key

# 需要导入模块: from skbio.stats.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.stats.distance.DissimilarityMatrix import from_iterable [as 别名]
    def test_from_iterable_no_key(self):
        iterable = (x for x in range(4))

        exp = DissimilarityMatrix([[0, 1, 2, 3],
                                   [1, 0, 1, 2],
                                   [2, 1, 0, 1],
                                   [3, 2, 1, 0]])
        res = DissimilarityMatrix.from_iterable(iterable,
                                                lambda a, b: abs(b - a))
        self.assertEqual(res, exp)
开发者ID:jakereps,项目名称:scikit-bio,代码行数:12,代码来源:test_base.py

示例5: test_from_iterable_with_key

# 需要导入模块: from skbio.stats.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.stats.distance.DissimilarityMatrix import from_iterable [as 别名]
    def test_from_iterable_with_key(self):
        iterable = (x for x in range(4))

        exp = DissimilarityMatrix([[0, 1, 2, 3],
                                   [1, 0, 1, 2],
                                   [2, 1, 0, 1],
                                   [3, 2, 1, 0]], ['0', '1', '4', '9'])
        res = DissimilarityMatrix.from_iterable(iterable,
                                                lambda a, b: abs(b - a),
                                                key=lambda x: str(x ** 2))
        self.assertEqual(res, exp)
开发者ID:jakereps,项目名称:scikit-bio,代码行数:13,代码来源:test_base.py

示例6: test_from_iterable_skbio_hamming_metric_with_metadata

# 需要导入模块: from skbio.stats.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.stats.distance.DissimilarityMatrix import from_iterable [as 别名]
    def test_from_iterable_skbio_hamming_metric_with_metadata(self):
        # test for #1254
        seqs = [
            Sequence('ACGT'),
            Sequence('ACGA', metadata={'id': 'seq1'}),
            Sequence('AAAA', metadata={'id': 'seq2'}),
            Sequence('AAAA', positional_metadata={'qual': range(4)})
        ]

        exp = DissimilarityMatrix([
            [0, 0.25, 0.75, 0.75],
            [0.25, 0.0, 0.5, 0.5],
            [0.75, 0.5, 0.0, 0.0],
            [0.75, 0.5, 0.0, 0.0]], ['a', 'b', 'c', 'd'])

        dm = DissimilarityMatrix.from_iterable(
            seqs,
            metric=skbio.sequence.distance.hamming,
            keys=['a', 'b', 'c', 'd'])

        self.assertEqual(dm, exp)
开发者ID:jakereps,项目名称:scikit-bio,代码行数:23,代码来源:test_base.py

示例7: test_from_iterable_single

# 需要导入模块: from skbio.stats.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.stats.distance.DissimilarityMatrix import from_iterable [as 别名]
 def test_from_iterable_single(self):
     exp = DissimilarityMatrix([[100]])
     res = DissimilarityMatrix.from_iterable(["boo"], lambda a, b: 100)
     self.assertEqual(res, exp)
开发者ID:jakereps,项目名称:scikit-bio,代码行数:6,代码来源:test_base.py

示例8: test_from_iterable_empty

# 需要导入模块: from skbio.stats.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.stats.distance.DissimilarityMatrix import from_iterable [as 别名]
 def test_from_iterable_empty(self):
     with self.assertRaises(DissimilarityMatrixError):
         DissimilarityMatrix.from_iterable([], lambda x: x)
开发者ID:jakereps,项目名称:scikit-bio,代码行数:5,代码来源:test_base.py


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