本文整理汇总了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'])
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)