MCPcopy Index your code
hub / github.com/numpy/numpy / test_permutation_subclass

Method test_permutation_subclass

numpy/random/tests/test_regression.py:131–151  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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(

Callers

nothing calls this directly

Calls 4

__array__Method · 0.95
assert_array_equalFunction · 0.90
MClass · 0.70
viewMethod · 0.45

Tested by

no test coverage detected