Simple algorithm to select a subset of 'vectors' (each with N items) to cover every parameter pair. With 'min_cover_count'=1 all pairs will be covered (if possible), for bigger values only those vectors will be selected that cover at least 'min_cover_count' new pairs
(self, vectors, results, pairs_covered, min_cover_count)
| 316 | return True |
| 317 | |
| 318 | def __pairwise_step(self, vectors, results, pairs_covered, min_cover_count): |
| 319 | """ Simple algorithm to select a subset of 'vectors' (each with N items) to cover |
| 320 | every parameter pair. |
| 321 | With 'min_cover_count'=1 all pairs will be covered (if possible), for bigger |
| 322 | values only those vectors will be selected that cover at least 'min_cover_count' |
| 323 | new pairs and the unused vectors will be returned in the result of the function. |
| 324 | 'pairs_covered' is a set of the already covered pairs. The key is a tuple of 4 |
| 325 | elements (i, v[i], j, v[j]) where i<j and both are < N. Each vector covers |
| 326 | N * (N - 1) pairs. |
| 327 | """ |
| 328 | remaining = [] |
| 329 | for v in vectors: |
| 330 | cnt = 0 |
| 331 | for i, x in enumerate(v): |
| 332 | for j, y in enumerate(v[i + 1:], i + 1): |
| 333 | t = (i, x, j, y) |
| 334 | if t not in pairs_covered: |
| 335 | cnt += 1 |
| 336 | if cnt == 0: continue |
| 337 | if cnt < min_cover_count: |
| 338 | remaining.append(v) |
| 339 | continue |
| 340 | results.append(v) |
| 341 | for i, x in enumerate(v): |
| 342 | for j, y in enumerate(v[i + 1:], i + 1): |
| 343 | t = (i, x, j, y) |
| 344 | pairs_covered.add(t) |
| 345 | return remaining |
no test coverage detected