(device)
| 237 | |
| 238 | |
| 239 | def _test_too_many_indices(device): |
| 240 | data = [np.uint8([1, 2, 3]), np.uint8([1, 2])] |
| 241 | src = fn.external_source(lambda: data, device=device) |
| 242 | pipe = index_pipe(src, lambda x: x[1, :]) |
| 243 | |
| 244 | # Verified by _tensor_subscript |
| 245 | with assert_raises(RuntimeError, glob="Too many indices"): |
| 246 | _ = pipe.run() |
| 247 | |
| 248 | # Verified by _subscript_dim_check |
| 249 | pipe = index_pipe(src, lambda x: x[:, :]) |
| 250 | with assert_raises(RuntimeError, glob="Too many indices"): |
| 251 | _ = pipe.run() |
| 252 | |
| 253 | # Verified by expand_dims |
| 254 | pipe = index_pipe(src, lambda x: x[:, :, dali.newaxis]) |
| 255 | with assert_raises(RuntimeError, glob="not enough dimensions"): |
| 256 | _ = pipe.run() |
| 257 | |
| 258 | # Verified by _subscript_dim_check |
| 259 | pipe = index_pipe(src, lambda x: x[dali.newaxis, :, dali.newaxis, :]) |
| 260 | with assert_raises(RuntimeError, glob="Too many indices"): |
| 261 | _ = pipe.run() |
| 262 | |
| 263 | |
| 264 | def test_zero_stride_error(): |
nothing calls this directly
no test coverage detected