| 31 | |
| 32 | |
| 33 | def test_normal_decoding(): |
| 34 | num_samples = 8 |
| 35 | data = [np.random.normal(size=(2, s)).astype(np.float32) for s in range(num_samples)] |
| 36 | |
| 37 | @pipeline_def(batch_size=1, num_threads=1) |
| 38 | def pipe(): |
| 39 | encoded_npy = fn.external_source( |
| 40 | source=box_source(data), num_outputs=1, batch=False, ndim=1, dtype=DALIDataType.UINT8 |
| 41 | ) |
| 42 | decoded = fn.decoders.numpy(encoded_npy) |
| 43 | return decoded |
| 44 | |
| 45 | p = pipe() |
| 46 | p.build() |
| 47 | |
| 48 | for i in range(num_samples): |
| 49 | output = p.run() |
| 50 | test = np.asarray(output[0][0]) |
| 51 | assert np.all(test == data[i]) |
| 52 | |
| 53 | |
| 54 | def test_fortran_decoding(): |