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

Function test_iter_f_order

numpy/_core/tests/test_nditer.py:143–168  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

141 aview.swapaxes(0, 1).ravel(order='C'))
142
143def test_iter_f_order():
144 # Test forcing F order
145
146 # Test the ordering for 1-D to 5-D shapes
147 for shape in [(5,), (3, 4), (2, 3, 4), (2, 3, 4, 3), (2, 3, 2, 2, 3)]:
148 a = arange(np.prod(shape))
149 # Test each combination of positive and negative strides
150 for dirs in range(2**len(shape)):
151 dirs_index = [slice(None)] * len(shape)
152 for bit in range(len(shape)):
153 if ((2**bit) & dirs):
154 dirs_index[bit] = slice(None, None, -1)
155 dirs_index = tuple(dirs_index)
156
157 aview = a.reshape(shape)[dirs_index]
158 # C-order
159 i = nditer(aview, order='F')
160 assert_equal(list(i), aview.ravel(order='F'))
161 # Fortran-order
162 i = nditer(aview.T, order='F')
163 assert_equal(list(i), aview.T.ravel(order='F'))
164 # Other order
165 if len(shape) > 2:
166 i = nditer(aview.swapaxes(0, 1), order='F')
167 assert_equal(list(i),
168 aview.swapaxes(0, 1).ravel(order='F'))
169
170def test_iter_c_or_f_order():
171 # Test forcing any contiguous (C or F) order

Callers

nothing calls this directly

Calls 5

assert_equalFunction · 0.90
sliceFunction · 0.85
reshapeMethod · 0.80
prodMethod · 0.45
ravelMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…