|
a |
|
b/sandbox/test_idx.py |
|
|
1 |
import numpy as np |
|
|
2 |
|
|
|
3 |
x = np.arange(21) |
|
|
4 |
|
|
|
5 |
part_out_of = (1, 3) |
|
|
6 |
this_part = part_out_of[0] |
|
|
7 |
all_parts = part_out_of[1] |
|
|
8 |
part_lenght = int(len(x) / all_parts) |
|
|
9 |
|
|
|
10 |
if this_part == all_parts: |
|
|
11 |
x1 = x[part_lenght * (this_part - 1):] |
|
|
12 |
else: |
|
|
13 |
x1 = x[part_lenght * (this_part - 1): part_lenght * this_part] |
|
|
14 |
|
|
|
15 |
print x1 |
|
|
16 |
|
|
|
17 |
part_out_of = (2, 3) |
|
|
18 |
this_part = part_out_of[0] |
|
|
19 |
all_parts = part_out_of[1] |
|
|
20 |
part_lenght = int(len(x) / all_parts) |
|
|
21 |
|
|
|
22 |
if this_part == all_parts: |
|
|
23 |
x1 = x[part_lenght * (this_part - 1):] |
|
|
24 |
else: |
|
|
25 |
x1 = x[part_lenght * (this_part - 1): part_lenght * this_part] |
|
|
26 |
|
|
|
27 |
print x1 |
|
|
28 |
|
|
|
29 |
part_out_of = (3, 3) |
|
|
30 |
this_part = part_out_of[0] |
|
|
31 |
all_parts = part_out_of[1] |
|
|
32 |
part_lenght = int(len(x) / all_parts) |
|
|
33 |
|
|
|
34 |
if this_part == all_parts: |
|
|
35 |
x1 = x[part_lenght * (this_part - 1):] |
|
|
36 |
else: |
|
|
37 |
x1 = x[part_lenght * (this_part - 1): part_lenght * this_part] |
|
|
38 |
|
|
|
39 |
print x1 |
|
|
40 |
|
|
|
41 |
part_out_of = (4, 3) |
|
|
42 |
this_part = part_out_of[0] |
|
|
43 |
all_parts = part_out_of[1] |
|
|
44 |
part_lenght = int(len(x) / all_parts) |
|
|
45 |
|
|
|
46 |
if this_part == all_parts: |
|
|
47 |
x1 = x[part_lenght * (this_part - 1):] |
|
|
48 |
else: |
|
|
49 |
x1 = x[part_lenght * (this_part - 1): part_lenght * this_part] |
|
|
50 |
|
|
|
51 |
print x1 |