本文整理汇总了Python中idtxl.data.Data._swap_blocks方法的典型用法代码示例。如果您正苦于以下问题:Python Data._swap_blocks方法的具体用法?Python Data._swap_blocks怎么用?Python Data._swap_blocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idtxl.data.Data
的用法示例。
在下文中一共展示了Data._swap_blocks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_swap_blocks
# 需要导入模块: from idtxl.data import Data [as 别名]
# 或者: from idtxl.data.Data import _swap_blocks [as 别名]
def test_swap_blocks():
"""Test block-wise swapping of samples."""
d = Data()
d.generate_mute_data()
# block_size divides the length of the data to be permuted, swap_range
# leads to 2 remaining blocks
n = 50
block_size = 5
swap_range = 4
perm = d._swap_blocks(n, block_size, swap_range)
assert perm.shape[0] == n, 'Incorrect length of permuted indices.'
# block_size leads to one block of length 1, swap_range divides the no.
# blocks
n = 50
block_size = 7
swap_range = 4
perm = d._swap_blocks(n, block_size, swap_range)
assert perm.shape[0] == n, 'Incorrect length of permuted indices.'
n_blocks = np.ceil(n/7).astype(int)
assert n_blocks == 8, 'No. blocks is incorrect.'
assert sum(perm == n_blocks - 1) == 1, ('No. remaining samples in the last'
' block is incorrect.')
# no remaining samples or blocks
n = 30
block_size = 5
swap_range = 3
perm = d._swap_blocks(n, block_size, swap_range)
assert perm.shape[0] == n, 'Incorrect length of permuted indices.'