本文整理汇总了Python中skbio.stats.distance.randdm函数的典型用法代码示例。如果您正苦于以下问题:Python randdm函数的具体用法?Python randdm怎么用?Python randdm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了randdm函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_random_fn
def test_random_fn(self):
def myrand(num_rows, num_cols):
# One dm to rule them all...
data = np.empty((num_rows, num_cols))
data.fill(42)
return data
exp = DistanceMatrix(np.asarray([[0, 42, 42], [42, 0, 42],
[42, 42, 0]]), ['1', '2', '3'])
obs = randdm(3, random_fn=myrand)
self.assertEqual(obs, exp)
示例2: test_default_usage
def test_default_usage(self):
exp = DistanceMatrix(np.asarray([[0.0]]), ['1'])
obs = randdm(1)
self.assertEqual(obs, exp)
obs = randdm(2)
self.assertEqual(obs.shape, (2, 2))
self.assertEqual(obs.ids, ('1', '2'))
obs1 = randdm(5)
num_trials = 10
found_diff = False
for _ in range(num_trials):
obs2 = randdm(5)
if obs1 != obs2:
found_diff = True
break
self.assertTrue(found_diff)
示例3: test_invalid_input
def test_invalid_input(self):
# Invalid dimensions.
with self.assertRaises(DissimilarityMatrixError):
randdm(0)
# Invalid dimensions.
with self.assertRaises(ValueError):
randdm(-1)
# Invalid number of IDs.
with self.assertRaises(DissimilarityMatrixError):
randdm(2, ids=['foo'])
示例4: test_constructor
def test_constructor(self):
exp = DissimilarityMatrix(np.asarray([[0.0]]), ['1'])
obs = randdm(1, constructor=DissimilarityMatrix)
self.assertEqual(obs, exp)
self.assertEqual(type(obs), DissimilarityMatrix)
示例5: test_ids
def test_ids(self):
ids = ['foo', 'bar', 'baz']
obs = randdm(3, ids=ids)
self.assertEqual(obs.shape, (3, 3))
self.assertEqual(obs.ids, tuple(ids))
示例6: test_large_matrix_for_symmetry
def test_large_matrix_for_symmetry(self):
obs3 = randdm(100)
self.assertEqual(obs3, obs3.T)