本文整理汇总了Python中idtxl.data.Data.slice_permute_samples方法的典型用法代码示例。如果您正苦于以下问题:Python Data.slice_permute_samples方法的具体用法?Python Data.slice_permute_samples怎么用?Python Data.slice_permute_samples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idtxl.data.Data
的用法示例。
在下文中一共展示了Data.slice_permute_samples方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_data_type
# 需要导入模块: from idtxl.data import Data [as 别名]
# 或者: from idtxl.data.Data import slice_permute_samples [as 别名]
def test_data_type():
"""Test if data class always returns the correct data type."""
# Change data type for the same object instance.
d_int = np.random.randint(0, 10, size=(3, 50))
orig_type = type(d_int[0][0])
data = Data(d_int, dim_order='ps', normalise=False)
# The concrete type depends on the platform:
# https://mail.scipy.org/pipermail/numpy-discussion/2011-November/059261.html
# Hence, compare against the type automatically assigned by Python or
# against np.integer
assert data.data_type is orig_type, 'Data type did not change.'
assert issubclass(type(data.data[0, 0, 0]), np.integer), (
'Data type is not an int.')
d_float = np.random.randn(3, 50)
data.set_data(d_float, dim_order='ps')
assert data.data_type is np.float64, 'Data type did not change.'
assert issubclass(type(data.data[0, 0, 0]), np.float), (
'Data type is not a float.')
# Check if data returned by the object have the correct type.
d_int = np.random.randint(0, 10, size=(3, 50, 5))
data = Data(d_int, dim_order='psr', normalise=False)
real = data.get_realisations((0, 5), [(1, 1), (1, 3)])[0]
assert issubclass(type(real[0, 0]), np.integer), (
'Realisations type is not an int.')
sl = data._get_data_slice(0)[0]
assert issubclass(type(sl[0, 0]), np.integer), (
'Data slice type is not an int.')
settings = {'perm_type': 'random'}
sl_perm = data.slice_permute_samples(0, settings)[0]
assert issubclass(type(sl_perm[0, 0]), np.integer), (
'Permuted data slice type is not an int.')
samples = data.permute_samples((0, 5), [(1, 1), (1, 3)], settings)[0]
assert issubclass(type(samples[0, 0]), np.integer), (
'Permuted samples type is not an int.')