MCPcopy
hub / github.com/nitrain/nitrain / create_slices

Function create_slices

nitrain/samplers/slice.py:68–80  ·  view source on GitHub ↗
(x, axis)

Source from the content-addressed store, hash-verified

66 return x[idx]
67
68def create_slices(x, axis):
69 def flatten_extend(matrix):
70 flat_list = []
71 for row in matrix:
72 flat_list.extend(row)
73 return flat_list
74
75 if isinstance(x[0], list):
76 return [create_slices([x[i][j] for i in range(len(x))], axis) for j in range(len(x[0]))]
77 if ants.is_image(x[0]):
78 return flatten_extend([[xx.slice_image(axis, i) for i in range(xx.shape[axis])] for xx in x])
79 else:
80 return x

Callers 4

test_create_slicesMethod · 0.90
test_nested_slicesMethod · 0.90
__call__Method · 0.85
__call__Method · 0.85

Calls 1

flatten_extendFunction · 0.85

Tested by 2

test_create_slicesMethod · 0.72
test_nested_slicesMethod · 0.72