(self)
| 127 | gc.collect() |
| 128 | |
| 129 | def test_permutation_subclass(self): |
| 130 | class N(np.ndarray): |
| 131 | pass |
| 132 | |
| 133 | np.random.seed(1) |
| 134 | orig = np.arange(3).view(N) |
| 135 | perm = np.random.permutation(orig) |
| 136 | assert_array_equal(perm, np.array([0, 2, 1])) |
| 137 | assert_array_equal(orig, np.arange(3).view(N)) |
| 138 | |
| 139 | class M: |
| 140 | a = np.arange(5) |
| 141 | |
| 142 | def __array__(self): |
| 143 | return self.a |
| 144 | |
| 145 | np.random.seed(1) |
| 146 | m = M() |
| 147 | perm = np.random.permutation(m) |
| 148 | assert_array_equal(perm, np.array([2, 1, 4, 0, 3])) |
| 149 | assert_array_equal(m.__array__(), np.arange(5)) |
nothing calls this directly
no test coverage detected