()
| 105 | assert_equal([x for x in i], a) |
| 106 | |
| 107 | def test_iter_c_order(): |
| 108 | # Test forcing C order |
| 109 | |
| 110 | # Test the ordering for 1-D to 5-D shapes |
| 111 | for shape in [(5,), (3, 4), (2, 3, 4), (2, 3, 4, 3), (2, 3, 2, 2, 3)]: |
| 112 | a = arange(np.prod(shape)) |
| 113 | # Test each combination of positive and negative strides |
| 114 | for dirs in range(2**len(shape)): |
| 115 | dirs_index = [slice(None)]*len(shape) |
| 116 | for bit in range(len(shape)): |
| 117 | if ((2**bit) & dirs): |
| 118 | dirs_index[bit] = slice(None, None, -1) |
| 119 | dirs_index = tuple(dirs_index) |
| 120 | |
| 121 | aview = a.reshape(shape)[dirs_index] |
| 122 | # C-order |
| 123 | i = nditer(aview, order='C') |
| 124 | assert_equal([x for x in i], aview.ravel(order='C')) |
| 125 | # Fortran-order |
| 126 | i = nditer(aview.T, order='C') |
| 127 | assert_equal([x for x in i], aview.T.ravel(order='C')) |
| 128 | # Other order |
| 129 | if len(shape) > 2: |
| 130 | i = nditer(aview.swapaxes(0, 1), order='C') |
| 131 | assert_equal([x for x in i], |
| 132 | aview.swapaxes(0, 1).ravel(order='C')) |
| 133 | |
| 134 | def test_iter_f_order(): |
| 135 | # Test forcing F order |
nothing calls this directly
no test coverage detected