MCPcopy Create free account
hub / github.com/numpy/numpy / test_permutation_subclass

Method test_permutation_subclass

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

Source from the content-addressed store, hash-verified

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))

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