本文整理汇总了Python中skbio.util._testing.assert_data_frame_almost_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_data_frame_almost_equal函数的具体用法?Python assert_data_frame_almost_equal怎么用?Python assert_data_frame_almost_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_data_frame_almost_equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_init_default_parameters
def test_init_default_parameters(self):
seq = ExampleGrammaredSequence('.-ABCXYZ')
npt.assert_equal(seq.values, np.array('.-ABCXYZ', dtype='c'))
self.assertEqual(seq.metadata, {})
assert_data_frame_almost_equal(seq.positional_metadata,
pd.DataFrame(index=range(8)))
开发者ID:bassio,项目名称:scikit-bio,代码行数:7,代码来源:test_grammared_sequence.py
示例2: test_positional_metadata_getter_no_positional_metadata
def test_positional_metadata_getter_no_positional_metadata(self):
obj = self._positional_metadata_constructor_(4)
self.assertIsInstance(obj.positional_metadata, pd.DataFrame)
assert_data_frame_almost_equal(
obj.positional_metadata,
pd.DataFrame(index=np.arange(4)))
开发者ID:bassio,项目名称:scikit-bio,代码行数:7,代码来源:_testing.py
示例3: test_positional_metadata_deleter
def test_positional_metadata_deleter(self):
obj = self._positional_metadata_constructor_(
3, positional_metadata={'foo': [1, 2, 3]})
self.assertIsInstance(obj.positional_metadata.index, pd.RangeIndex)
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame({'foo': [1, 2, 3]}))
del obj.positional_metadata
self.assertIsInstance(obj.positional_metadata.index, pd.RangeIndex)
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame(index=range(3)))
# Delete again.
del obj.positional_metadata
self.assertIsInstance(obj.positional_metadata.index, pd.RangeIndex)
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame(index=range(3)))
obj = self._positional_metadata_constructor_(3)
self.assertIsInstance(obj.positional_metadata.index, pd.RangeIndex)
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame(index=range(3)))
del obj.positional_metadata
self.assertIsInstance(obj.positional_metadata.index, pd.RangeIndex)
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame(index=range(3)))
开发者ID:anderspitman,项目名称:scikit-bio,代码行数:28,代码来源:_testing.py
示例4: test_deepcopy_with_positional_metadata
def test_deepcopy_with_positional_metadata(self):
obj = self._positional_metadata_constructor_(
4, positional_metadata={'bar': [[], [], [], []],
'baz': [42, 42, 42, 42]})
obj_copy = copy.deepcopy(obj)
self.assertEqual(obj, obj_copy)
self.assertIsNot(obj, obj_copy)
self.assertIsNot(obj._positional_metadata,
obj_copy._positional_metadata)
self.assertIsNot(obj._positional_metadata.values,
obj_copy._positional_metadata.values)
self.assertIsNot(obj._positional_metadata.loc[0, 'bar'],
obj_copy._positional_metadata.loc[0, 'bar'])
obj_copy.positional_metadata.loc[0, 'bar'].append(1)
obj_copy.positional_metadata.loc[0, 'baz'] = 43
assert_data_frame_almost_equal(
obj_copy.positional_metadata,
pd.DataFrame({'bar': [[1], [], [], []],
'baz': [43, 42, 42, 42]}))
assert_data_frame_almost_equal(
obj.positional_metadata,
pd.DataFrame({'bar': [[], [], [], []],
'baz': [42, 42, 42, 42]}))
开发者ID:jakereps,项目名称:scikit-bio,代码行数:27,代码来源:_testing.py
示例5: test_constructor_with_positional_metadata_len_zero
def test_constructor_with_positional_metadata_len_zero(self):
for data in [], (), np.array([]):
obj = self._positional_metadata_constructor_(
0, positional_metadata={'foo': data})
assert_data_frame_almost_equal(
obj.positional_metadata,
pd.DataFrame({'foo': data}, index=np.arange(0)))
开发者ID:bassio,项目名称:scikit-bio,代码行数:8,代码来源:_testing.py
示例6: test_constructor_with_positional_metadata_len_one
def test_constructor_with_positional_metadata_len_one(self):
for data in [2], (2, ), np.array([2]):
obj = self._positional_metadata_constructor_(
1, positional_metadata={'foo': data})
assert_data_frame_almost_equal(
obj.positional_metadata,
pd.DataFrame({'foo': data}, index=range(1)))
开发者ID:anderspitman,项目名称:scikit-bio,代码行数:8,代码来源:_testing.py
示例7: test_constructor_with_positional_metadata_multiple_columns
def test_constructor_with_positional_metadata_multiple_columns(self):
obj = self._positional_metadata_constructor_(
5, positional_metadata={'foo': np.arange(5),
'bar': np.arange(5)[::-1]})
assert_data_frame_almost_equal(
obj.positional_metadata,
pd.DataFrame({'foo': np.arange(5),
'bar': np.arange(5)[::-1]}, index=range(5)))
开发者ID:anderspitman,项目名称:scikit-bio,代码行数:9,代码来源:_testing.py
示例8: test_constructor_with_positional_metadata_len_greater_than_one
def test_constructor_with_positional_metadata_len_greater_than_one(self):
for data in ([0, 42, 42, 1, 0, 8, 100, 0, 0],
(0, 42, 42, 1, 0, 8, 100, 0, 0),
np.array([0, 42, 42, 1, 0, 8, 100, 0, 0])):
obj = self._positional_metadata_constructor_(
9, positional_metadata={'foo': data})
assert_data_frame_almost_equal(
obj.positional_metadata,
pd.DataFrame({'foo': data}, index=range(9)))
开发者ID:anderspitman,项目名称:scikit-bio,代码行数:10,代码来源:_testing.py
示例9: test_constructor_with_positional_metadata_custom_index
def test_constructor_with_positional_metadata_custom_index(self):
df = pd.DataFrame({'foo': np.arange(5), 'bar': np.arange(5)[::-1]},
index=['a', 'b', 'c', 'd', 'e'])
obj = self._positional_metadata_constructor_(
5, positional_metadata=df)
assert_data_frame_almost_equal(
obj.positional_metadata,
pd.DataFrame({'foo': np.arange(5),
'bar': np.arange(5)[::-1]}, index=range(5)))
开发者ID:anderspitman,项目名称:scikit-bio,代码行数:10,代码来源:_testing.py
示例10: test_positional_metadata_getter_no_positional_metadata
def test_positional_metadata_getter_no_positional_metadata(self):
obj = self._positional_metadata_constructor_(4)
self.assertIsNone(obj._positional_metadata)
self.assertIsInstance(obj.positional_metadata, pd.DataFrame)
self.assertIsInstance(obj.positional_metadata.index, pd.RangeIndex)
assert_data_frame_almost_equal(
obj.positional_metadata,
pd.DataFrame(index=range(4)))
self.assertIsNotNone(obj._positional_metadata)
开发者ID:jakereps,项目名称:scikit-bio,代码行数:10,代码来源:_testing.py
示例11: test_init_nondefault_parameters
def test_init_nondefault_parameters(self):
seq = ExampleGrammaredSequence(
'.-ABCXYZ',
metadata={'id': 'foo'},
positional_metadata={'quality': range(8)})
npt.assert_equal(seq.values, np.array('.-ABCXYZ', dtype='c'))
self.assertEqual(seq.metadata, {'id': 'foo'})
assert_data_frame_almost_equal(seq.positional_metadata,
pd.DataFrame({'quality': range(8)}))
开发者ID:bassio,项目名称:scikit-bio,代码行数:10,代码来源:test_grammared_sequence.py
示例12: test_deepcopy_positional_metadata_empty
def test_deepcopy_positional_metadata_empty(self):
obj = self._positional_metadata_constructor_(
3, positional_metadata=pd.DataFrame(index=range(3)))
obj_copy = copy.deepcopy(obj)
self.assertEqual(obj, obj_copy)
self.assertIsNot(obj, obj_copy)
assert_data_frame_almost_equal(obj._positional_metadata,
pd.DataFrame(index=range(3)))
self.assertIsNone(obj_copy._positional_metadata)
开发者ID:jakereps,项目名称:scikit-bio,代码行数:11,代码来源:_testing.py
示例13: test_positional_metadata_setter_invalid_type
def test_positional_metadata_setter_invalid_type(self):
obj = self._positional_metadata_constructor_(
3, positional_metadata={'foo': [1, 2, 42]})
with self.assertRaisesRegex(TypeError,
'Invalid positional metadata. Must be '
'consumable by `pd.DataFrame` constructor.'
' Original pandas error message: '):
obj.positional_metadata = 2
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame({'foo': [1, 2, 42]}))
开发者ID:anderspitman,项目名称:scikit-bio,代码行数:12,代码来源:_testing.py
示例14: test_positional_metadata_setter_none
def test_positional_metadata_setter_none(self):
obj = self._positional_metadata_constructor_(
0, positional_metadata={'foo': []})
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame({'foo': []}))
# `None` behavior differs from constructor.
obj.positional_metadata = None
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame(index=range(0)))
开发者ID:anderspitman,项目名称:scikit-bio,代码行数:12,代码来源:_testing.py
示例15: test_copy_positional_metadata_none
def test_copy_positional_metadata_none(self):
obj = self._positional_metadata_constructor_(3)
obj_copy = copy.copy(obj)
self.assertEqual(obj, obj_copy)
self.assertIsNot(obj, obj_copy)
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame(index=range(3)))
assert_data_frame_almost_equal(obj_copy.positional_metadata,
pd.DataFrame(index=range(3)))
self.assertIsNot(obj.positional_metadata, obj_copy.positional_metadata)
开发者ID:anderspitman,项目名称:scikit-bio,代码行数:12,代码来源:_testing.py
示例16: test_positional_metadata_setter_pandas_consumable
def test_positional_metadata_setter_pandas_consumable(self):
obj = self._positional_metadata_constructor_(3)
self.assertFalse(obj.has_positional_metadata())
obj.positional_metadata = {'foo': [3, 2, 1]}
self.assertTrue(obj.has_positional_metadata())
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame({'foo': [3, 2, 1]}))
obj.positional_metadata = pd.DataFrame(index=np.arange(3))
self.assertFalse(obj.has_positional_metadata())
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame(index=range(3)))
开发者ID:jakereps,项目名称:scikit-bio,代码行数:14,代码来源:_testing.py
示例17: test_constructor_with_positional_metadata_int64_index
def test_constructor_with_positional_metadata_int64_index(self):
# Test that memory-inefficient index is converted to memory-efficient
# index.
df = pd.DataFrame({'foo': np.arange(5), 'bar': np.arange(5)[::-1]},
index=np.arange(5))
self.assertIsInstance(df.index, pd.Int64Index)
obj = self._positional_metadata_constructor_(
5, positional_metadata=df)
assert_data_frame_almost_equal(
obj.positional_metadata,
pd.DataFrame({'foo': np.arange(5),
'bar': np.arange(5)[::-1]}, index=range(5)))
self.assertIsInstance(obj.positional_metadata.index, pd.RangeIndex)
开发者ID:anderspitman,项目名称:scikit-bio,代码行数:15,代码来源:_testing.py
示例18: test_constructor_no_positional_metadata
def test_constructor_no_positional_metadata(self):
# Length zero with missing/empty positional metadata.
for empty in None, {}, pd.DataFrame():
obj = self._positional_metadata_constructor_(
0, positional_metadata=empty)
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame(index=np.arange(0)))
# Nonzero length with missing positional metadata.
obj = self._positional_metadata_constructor_(
3, positional_metadata=None)
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame(index=np.arange(3)))
开发者ID:bassio,项目名称:scikit-bio,代码行数:15,代码来源:_testing.py
示例19: test_positional_metadata_setter_len_mismatch
def test_positional_metadata_setter_len_mismatch(self):
obj = self._positional_metadata_constructor_(
3, positional_metadata={'foo': [1, 2, 42]})
# `None` behavior differs from constructor.
with self.assertRaisesRegex(ValueError, '\(0\).*\(3\)'):
obj.positional_metadata = None
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame({'foo': [1, 2, 42]}))
with self.assertRaisesRegex(ValueError, '\(4\).*\(3\)'):
obj.positional_metadata = [1, 2, 3, 4]
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame({'foo': [1, 2, 42]}))
开发者ID:anderspitman,项目名称:scikit-bio,代码行数:16,代码来源:_testing.py
示例20: test_positional_metadata_setter_data_frame
def test_positional_metadata_setter_data_frame(self):
obj = self._positional_metadata_constructor_(3)
self.assertFalse(obj.has_positional_metadata())
obj.positional_metadata = pd.DataFrame({'foo': [3, 2, 1]},
index=['a', 'b', 'c'])
self.assertTrue(obj.has_positional_metadata())
self.assertIsInstance(obj.positional_metadata.index, pd.RangeIndex)
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame({'foo': [3, 2, 1]}))
obj.positional_metadata = pd.DataFrame(index=np.arange(3))
self.assertFalse(obj.has_positional_metadata())
assert_data_frame_almost_equal(obj.positional_metadata,
pd.DataFrame(index=range(3)))
开发者ID:jakereps,项目名称:scikit-bio,代码行数:16,代码来源:_testing.py
注:本文中的skbio.util._testing.assert_data_frame_almost_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论