()
| 417 | |
| 418 | |
| 419 | def test_internal_overlap_slices(): |
| 420 | # Slicing an array never generates internal overlap |
| 421 | |
| 422 | x = np.zeros([17,34,71,97], dtype=np.int16) |
| 423 | |
| 424 | rng = np.random.RandomState(1234) |
| 425 | |
| 426 | def random_slice(n, step): |
| 427 | start = rng.randint(0, n+1, dtype=np.intp) |
| 428 | stop = rng.randint(start, n+1, dtype=np.intp) |
| 429 | if rng.randint(0, 2, dtype=np.intp) == 0: |
| 430 | stop, start = start, stop |
| 431 | step *= -1 |
| 432 | return slice(start, stop, step) |
| 433 | |
| 434 | cases = 0 |
| 435 | min_count = 5000 |
| 436 | |
| 437 | while cases < min_count: |
| 438 | steps = tuple(rng.randint(1, 11, dtype=np.intp) |
| 439 | if rng.randint(0, 5, dtype=np.intp) == 0 else 1 |
| 440 | for j in range(x.ndim)) |
| 441 | t1 = np.arange(x.ndim) |
| 442 | rng.shuffle(t1) |
| 443 | s1 = tuple(random_slice(p, s) for p, s in zip(x.shape, steps)) |
| 444 | a = x[s1].transpose(t1) |
| 445 | |
| 446 | assert_(not internal_overlap(a)) |
| 447 | cases += 1 |
| 448 | |
| 449 | |
| 450 | def check_internal_overlap(a, manual_expected=None): |
nothing calls this directly
no test coverage detected