(self, operation, get_out_axis_size, dtype=np.int16,
count=5000)
| 603 | """ |
| 604 | |
| 605 | def check_unary_fuzz(self, operation, get_out_axis_size, dtype=np.int16, |
| 606 | count=5000): |
| 607 | shapes = [7, 13, 8, 21, 29, 32] |
| 608 | |
| 609 | rng = np.random.RandomState(1234) |
| 610 | |
| 611 | for ndim in range(1, 6): |
| 612 | x = rng.randint(0, 2**16, size=shapes[:ndim]).astype(dtype) |
| 613 | |
| 614 | it = iter_random_view_pairs(x, same_steps=False, equal_size=True) |
| 615 | |
| 616 | min_count = count // (ndim + 1)**2 |
| 617 | |
| 618 | overlapping = 0 |
| 619 | while overlapping < min_count: |
| 620 | a, b = next(it) |
| 621 | |
| 622 | a_orig = a.copy() |
| 623 | b_orig = b.copy() |
| 624 | |
| 625 | if get_out_axis_size is None: |
| 626 | assert_copy_equivalent(operation, [a], out=b) |
| 627 | |
| 628 | if np.shares_memory(a, b): |
| 629 | overlapping += 1 |
| 630 | else: |
| 631 | for axis in itertools.chain(range(ndim), [None]): |
| 632 | a[...] = a_orig |
| 633 | b[...] = b_orig |
| 634 | |
| 635 | # Determine size for reduction axis (None if scalar) |
| 636 | outsize, scalarize = get_out_axis_size(a, b, axis) |
| 637 | if outsize == 'skip': |
| 638 | continue |
| 639 | |
| 640 | # Slice b to get an output array of the correct size |
| 641 | sl = [slice(None)] * ndim |
| 642 | if axis is None: |
| 643 | if outsize is None: |
| 644 | sl = [slice(0, 1)] + [0] * (ndim - 1) |
| 645 | else: |
| 646 | sl = [slice(0, outsize)] + [0] * (ndim - 1) |
| 647 | elif outsize is None: |
| 648 | k = b.shape[axis] // 2 |
| 649 | if ndim == 1: |
| 650 | sl[axis] = slice(k, k + 1) |
| 651 | else: |
| 652 | sl[axis] = k |
| 653 | else: |
| 654 | assert b.shape[axis] >= outsize |
| 655 | sl[axis] = slice(0, outsize) |
| 656 | b_out = b[tuple(sl)] |
| 657 | |
| 658 | if scalarize: |
| 659 | b_out = b_out.reshape([]) |
| 660 | |
| 661 | if np.shares_memory(a, b_out): |
| 662 | overlapping += 1 |
no test coverage detected