(self)
| 129 | gc.collect() |
| 130 | |
| 131 | def test_permutation_subclass(self): |
| 132 | class N(np.ndarray): |
| 133 | pass |
| 134 | |
| 135 | rng = np.random.RandomState(1) |
| 136 | orig = np.arange(3).view(N) |
| 137 | perm = rng.permutation(orig) |
| 138 | assert_array_equal(perm, np.array([0, 2, 1])) |
| 139 | assert_array_equal(orig, np.arange(3).view(N)) |
| 140 | |
| 141 | class M: |
| 142 | a = np.arange(5) |
| 143 | |
| 144 | def __array__(self, dtype=None, copy=None): |
| 145 | return self.a |
| 146 | |
| 147 | rng = np.random.RandomState(1) |
| 148 | m = M() |
| 149 | perm = rng.permutation(m) |
| 150 | assert_array_equal(perm, np.array([2, 1, 4, 0, 3])) |
| 151 | assert_array_equal(m.__array__(), np.arange(5)) |
| 152 | |
| 153 | @pytest.mark.skipif(sys.flags.optimize == 2, reason="Python running -OO") |
| 154 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected