本文整理汇总了Python中mvpa2.datasets.base.Dataset.from_hdf5方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.from_hdf5方法的具体用法?Python Dataset.from_hdf5怎么用?Python Dataset.from_hdf5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mvpa2.datasets.base.Dataset
的用法示例。
在下文中一共展示了Dataset.from_hdf5方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_h5py_io
# 需要导入模块: from mvpa2.datasets.base import Dataset [as 别名]
# 或者: from mvpa2.datasets.base.Dataset import from_hdf5 [as 别名]
def test_h5py_io():
skip_if_no_external('h5py')
tempdir = tempfile.mkdtemp()
# store random dataset to file
ds = datasets['3dlarge']
ds.save(os.path.join(tempdir, 'plain.hdf5'))
# reload and check for identity
ds2 = Dataset.from_hdf5(os.path.join(tempdir, 'plain.hdf5'))
assert_array_equal(ds.samples, ds2.samples)
for attr in ds.sa:
assert_array_equal(ds.sa[attr].value, ds2.sa[attr].value)
for attr in ds.fa:
assert_array_equal(ds.fa[attr].value, ds2.fa[attr].value)
assert_true(len(ds.a.mapper), 2)
# since we have no __equal__ do at least some comparison
if __debug__:
# debug mode needs special test as it enhances the repr output
# with module info and id() appendix for objects
assert_equal('#'.join(repr(ds.a.mapper).split('#')[:-1]),
'#'.join(repr(ds2.a.mapper).split('#')[:-1]))
else:
assert_equal(repr(ds.a.mapper), repr(ds2.a.mapper))
#cleanup temp dir
shutil.rmtree(tempdir, ignore_errors=True)
示例2: test_h5py_io
# 需要导入模块: from mvpa2.datasets.base import Dataset [as 别名]
# 或者: from mvpa2.datasets.base.Dataset import from_hdf5 [as 别名]
def test_h5py_io(dsfile):
skip_if_no_external('h5py')
# store random dataset to file
ds = datasets['3dlarge']
ds.save(dsfile)
# reload and check for identity
ds2 = Dataset.from_hdf5(dsfile)
assert_array_equal(ds.samples, ds2.samples)
for attr in ds.sa:
assert_array_equal(ds.sa[attr].value, ds2.sa[attr].value)
for attr in ds.fa:
assert_array_equal(ds.fa[attr].value, ds2.fa[attr].value)
assert_true(len(ds.a.mapper), 2)
# since we have no __equal__ do at least some comparison
assert_equal(repr(ds.a.mapper), repr(ds2.a.mapper))
if __debug__:
# debug mode needs special test as it enhances the repr output
# with module info and id() appendix for objects
#
# INCORRECT slicing (:-1) since without any hash it results in
# empty list -- moreover we seems of not reporting ids with #
# any longer
#
#assert_equal('#'.join(repr(ds.a.mapper).split('#')[:-1]),
# '#'.join(repr(ds2.a.mapper).split('#')[:-1]))
pass