| 119 | @raises(RuntimeError, "All samples in the dataset must have the same number of dimensions") |
| 120 | @params(1, 2) |
| 121 | def test_raise_different_dims(batch_size): |
| 122 | data = [np.empty(shape, dtype=np.float32) for shape in [(2, 3), (2, 3), (2, 3, 4), (2, 3)]] |
| 123 | |
| 124 | @pipeline_def(batch_size=batch_size, num_threads=1) |
| 125 | def pipe(): |
| 126 | encoded_npy = fn.external_source( |
| 127 | source=box_source(data), num_outputs=1, batch=False, ndim=1, dtype=DALIDataType.UINT8 |
| 128 | ) |
| 129 | decoded = fn.decoders.numpy(encoded_npy) |
| 130 | return decoded |
| 131 | |
| 132 | p = pipe() |
| 133 | p.build() |
| 134 | for _ in range(len(data) // batch_size): |
| 135 | p.run() |
| 136 | |
| 137 | |
| 138 | @raises(RuntimeError, "Got bad magic string for numpy header") |