Skip to content

Commit

Permalink
Add more tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
  • Loading branch information
mzient committed Aug 2, 2021
1 parent d0e3369 commit 2391452
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
5 changes: 5 additions & 0 deletions dali/python/nvidia/dali/data_node.py
Expand Up @@ -152,6 +152,7 @@ def __getitem__(self, val):
# returns True if this index adds a new output dimension
def process_index(idx, dim):
if idx is None:
print("DUPA!")
idxs.append((None, None, None, None))
return True
elif isinstance(idx, slice):
Expand All @@ -164,6 +165,10 @@ def process_index(idx, dim):
if idx.name is not None:
new_axis_names.append(idx.name)
return True
elif idx is Ellipsis:
raise NotImplementedError("Ellipsis in indexing is not implemented")
elif isinstance(idx, (float, str)):
raise TypeError("Invalid type for an index: ", type)
else:
idxs.append((idx, None, None, None))
return False
Expand Down
12 changes: 6 additions & 6 deletions dali/test/python/test_dali_cpu_only.py
Expand Up @@ -89,9 +89,9 @@ def get_data():
pipe.set_outputs(outs)
assert_raises(RuntimeError, pipe.build)

#def test_gpu_op_bad_device():
# for device_id in [None, 0]:
# yield check_bad_device, device_id
def test_gpu_op_bad_device():
for device_id in [None, 0]:
yield check_bad_device, device_id

def check_mixed_op_bad_device(device_id):
pipe = Pipeline(batch_size=batch_size, num_threads=4, device_id=device_id)
Expand All @@ -100,9 +100,9 @@ def check_mixed_op_bad_device(device_id):
pipe.set_outputs(decoded)
assert_raises(RuntimeError, pipe.build)

#def test_mixed_op_bad_device():
# for device_id in [None, 0]:
# yield check_bad_device, device_id
def test_mixed_op_bad_device():
for device_id in [None, 0]:
yield check_bad_device, device_id

def test_image_decoder_cpu():
pipe = Pipeline(batch_size=batch_size, num_threads=4, device_id=None)
Expand Down
13 changes: 13 additions & 0 deletions dali/test/python/test_operator_subscript.py
Expand Up @@ -172,3 +172,16 @@ def _test_too_many_indices(device):
def test_too_many_indices():
for device in ["cpu", "gpu"]:
yield _test_too_many_indices, device

def test_stride_not_implemented():
data = [np.uint8([1,2,3]),np.uint8([1,2])]
src = fn.external_source(lambda: data)
src[::1]
with assert_raises(NotImplementedError):
src[::2]

def test_ellipsis_not_implemented():
data = [np.uint8([1,2,3]),np.uint8([1,2])]
src = fn.external_source(lambda: data)
with assert_raises(NotImplementedError):
src[...,:1]

0 comments on commit 2391452

Please sign in to comment.