()
| 78 | del it2 # avoid pyflakes unused variable warning |
| 79 | |
| 80 | def test_iter_best_order(): |
| 81 | # The iterator should always find the iteration order |
| 82 | # with increasing memory addresses |
| 83 | |
| 84 | # Test the ordering for 1-D to 5-D shapes |
| 85 | for shape in [(5,), (3, 4), (2, 3, 4), (2, 3, 4, 3), (2, 3, 2, 2, 3)]: |
| 86 | a = arange(np.prod(shape)) |
| 87 | # Test each combination of positive and negative strides |
| 88 | for dirs in range(2**len(shape)): |
| 89 | dirs_index = [slice(None)]*len(shape) |
| 90 | for bit in range(len(shape)): |
| 91 | if ((2**bit) & dirs): |
| 92 | dirs_index[bit] = slice(None, None, -1) |
| 93 | dirs_index = tuple(dirs_index) |
| 94 | |
| 95 | aview = a.reshape(shape)[dirs_index] |
| 96 | # C-order |
| 97 | i = nditer(aview, [], [['readonly']]) |
| 98 | assert_equal([x for x in i], a) |
| 99 | # Fortran-order |
| 100 | i = nditer(aview.T, [], [['readonly']]) |
| 101 | assert_equal([x for x in i], a) |
| 102 | # Other order |
| 103 | if len(shape) > 2: |
| 104 | i = nditer(aview.swapaxes(0, 1), [], [['readonly']]) |
| 105 | assert_equal([x for x in i], a) |
| 106 | |
| 107 | def test_iter_c_order(): |
| 108 | # Test forcing C order |
nothing calls this directly
no test coverage detected