当前位置: 首页>>代码示例>>Python>>正文


Python Dataset.from_hdf5方法代码示例

本文整理汇总了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)
开发者ID:psederberg,项目名称:PyMVPA,代码行数:31,代码来源:test_datasetng.py

示例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
开发者ID:PepGardiola,项目名称:PyMVPA,代码行数:32,代码来源:test_datasetng.py


注:本文中的mvpa2.datasets.base.Dataset.from_hdf5方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。