@contextmanager
def random_images(n, shape):
    dirname = mkdtemp()
    for i in range(n):
        fn = os.path.join(dirname, i % 'image.%d.png')
        x = np.random.randint(0, 255, size=shape).astype('i1')
        imsave(fn, x)

    try:
        yield os.path.join(dirname, '*.png')
    finally:
        shutil.rmtree(dirname)
dataset/ETHPy150Open dask/dask/dask/array/tests/test_image.py/random_images/swapped operands of `%`