MCPcopy Create free account
hub / github.com/NVIDIA/DALI / _test_too_many_indices

Function _test_too_many_indices

dali/test/python/operator_2/test_subscript.py:239–261  ·  view source on GitHub ↗
(device)

Source from the content-addressed store, hash-verified

237
238
239def _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
264def test_zero_stride_error():

Callers

nothing calls this directly

Calls 4

assert_raisesFunction · 0.90
index_pipeFunction · 0.85
uint8Method · 0.80
runMethod · 0.45

Tested by

no test coverage detected