def test_read_image(): pytest.importorskip('skimage') urlpath = os.path.join(here, 'data', 'images', 'beach57.tif') source = ImageSource(urlpath=urlpath) array = source.read() assert array.shape == (256, 252, 3) assert array.dtype == np.uint8
def test_read_images_with_multiple_concat_dims_with_pattern(): pytest.importorskip('skimage') from intake_xarray.image import ImageSource path = os.path.join(here, 'data', '{size}_{color}.tif') im = ImageSource(path, concat_dim=['size', 'color']) ds = im.read() assert ds.sel(color='red', size='little').shape == (64, 64, 3)
def test_read_images(): pytest.importorskip('skimage') from intake_xarray.image import ImageSource im = ImageSource(os.path.join(here, 'data', 'little_*.tif')) da = im.read() assert da.shape == (2, 64, 64, 3) assert da.dims == ('concat_dim', 'y', 'x', 'channel')
def test_read_images_with_pattern(): pytest.importorskip('skimage') from intake_xarray.image import ImageSource path = os.path.join(here, 'data', 'little_{color}.tif') im = ImageSource(path, concat_dim='color') da = im.read() assert da.shape == (2, 64, 64, 3) assert len(da.color) == 2 assert set(da.color.data) == set(['red', 'green'])
def test_read_images_as_glob_with_coerce(): pytest.importorskip('skimage') urlpath = os.path.join(here, 'data', 'images', '*') source = ImageSource(urlpath=urlpath, coerce_shape=(256, 256)) array = source.read() assert array.shape == (3, 256, 256, 3)
def test_read_images_as_glob_without_coerce_raises_error(): pytest.importorskip('skimage') urlpath = os.path.join(here, 'data', 'images', '*') source = ImageSource(urlpath=urlpath) with pytest.raises(ValueError, match='could not broadcast input array'): source.read()
def test_read_jpg_image(): pytest.importorskip('skimage') from intake_xarray.image import ImageSource im = ImageSource(os.path.join(here, 'data', 'dog.jpg')) da = im.read() assert da.shape == (192, 192)
def test_read_image(): pytest.importorskip('skimage') from intake_xarray.image import ImageSource im = ImageSource(os.path.join(here, 'data', 'little_red.tif')) da = im.read() assert da.shape == (64, 64, 3)