本文整理汇总了Python中skbio.stats.distance.DissimilarityMatrix.to_data_frame方法的典型用法代码示例。如果您正苦于以下问题:Python DissimilarityMatrix.to_data_frame方法的具体用法?Python DissimilarityMatrix.to_data_frame怎么用?Python DissimilarityMatrix.to_data_frame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skbio.stats.distance.DissimilarityMatrix
的用法示例。
在下文中一共展示了DissimilarityMatrix.to_data_frame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DissimilarityMatrixTests
# 需要导入模块: from skbio.stats.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.stats.distance.DissimilarityMatrix import to_data_frame [as 别名]
#.........这里部分代码省略.........
ax = axes[0]
self.assertEqual(ax.get_title(), 'Testplot')
xticks = []
for tick in ax.get_xticklabels():
xticks.append(tick.get_text())
self.assertEqual(xticks, ['0', 'one', '2', 'three', '4.000'])
yticks = []
for tick in ax.get_yticklabels():
yticks.append(tick.get_text())
self.assertEqual(yticks, ['0', 'one', '2', 'three', '4.000'])
def test_repr_png(self):
dm = self.dm_1x1
obs = dm._repr_png_()
self.assertIsInstance(obs, binary_type)
self.assertTrue(len(obs) > 0)
def test_repr_svg(self):
obs = self.dm_1x1._repr_svg_()
# print_figure(format='svg') can return text or bytes depending on the
# version of IPython
self.assertTrue(isinstance(obs, text_type) or
isinstance(obs, binary_type))
self.assertTrue(len(obs) > 0)
def test_png(self):
dm = self.dm_1x1
self.assertIsInstance(dm.png, Image)
def test_svg(self):
dm = self.dm_1x1
self.assertIsInstance(dm.svg, SVG)
def test_to_data_frame_1x1(self):
df = self.dm_1x1.to_data_frame()
exp = pd.DataFrame([[0.0]], index=['a'], columns=['a'])
assert_data_frame_almost_equal(df, exp)
def test_to_data_frame_3x3(self):
df = self.dm_3x3.to_data_frame()
exp = pd.DataFrame([[0.0, 0.01, 4.2],
[0.01, 0.0, 12.0],
[4.2, 12.0, 0.0]],
index=['a', 'b', 'c'], columns=['a', 'b', 'c'])
assert_data_frame_almost_equal(df, exp)
def test_to_data_frame_default_ids(self):
df = DissimilarityMatrix(self.dm_2x2_data).to_data_frame()
exp = pd.DataFrame([[0.0, 0.123],
[0.123, 0.0]],
index=['0', '1'], columns=['0', '1'])
assert_data_frame_almost_equal(df, exp)
def test_str(self):
for dm in self.dms:
obs = str(dm)
# Do some very light testing here to make sure we're getting a
# non-empty string back. We don't want to test the exact
# formatting.
self.assertTrue(obs)
def test_eq(self):
for dm in self.dms:
copy = dm.copy()
self.assertTrue(dm == dm)
self.assertTrue(copy == copy)