(lines, line_counts)
| 29 | return lines |
| 30 | |
| 31 | def get_splits(lines, line_counts): |
| 32 | all_lines = [] |
| 33 | line_idx = [] |
| 34 | file_mappings = [] |
| 35 | for i, l in enumerate(lines): |
| 36 | all_lines.extend(l) |
| 37 | line_idx.extend(list(range(len(l)))) |
| 38 | file_mappings.extend([i]*len(l)) |
| 39 | |
| 40 | indices = list(range(len(all_lines))) |
| 41 | random.shuffle(indices) |
| 42 | all_lines = [all_lines[idx] for idx in indices] |
| 43 | line_idx = [line_idx[idx] for idx in indices] |
| 44 | file_mappings = [file_mappings[idx] for idx in indices] |
| 45 | |
| 46 | splits = [] |
| 47 | mappings = [] |
| 48 | start = 0 |
| 49 | for end in line_counts: |
| 50 | end += start |
| 51 | splits.append(all_lines[start:end]) |
| 52 | mappings.append(format_mappings(line_idx[start:end], file_mappings[start:end])) |
| 53 | start = end |
| 54 | return splits, mappings |
| 55 | |
| 56 | def format_mappings(line_idx, file_mappings): |
| 57 | lines = [] |
no test coverage detected