Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 0.17.0 ()
---------------------------

NOTE: This drops pillow as a required dependency.


Version 0.16.3 (2024-07-04)
---------------------------

Expand Down
7 changes: 6 additions & 1 deletion datashader/tests/test_tiles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from __future__ import annotations

import pytest

import datashader as ds
import datashader.transfer_functions as tf

Expand Down Expand Up @@ -45,7 +48,7 @@ def mock_shader_func(agg, span=None):


def mock_post_render_func(img, **kwargs):
from PIL import ImageDraw
ImageDraw = pytest.importorskip("PIL.ImageDraw")

(x, y) = (5, 5)
info = "x={} / y={} / z={}, w={}, h={}".format(kwargs['x'],
Expand All @@ -62,6 +65,8 @@ def mock_post_render_func(img, **kwargs):
# TODO: mark with slow_test
@dask_skip
def test_render_tiles():
pytest.importorskip("PIL")

full_extent_of_data = (-500000, -500000,
500000, 500000)
levels = list(range(2))
Expand Down
4 changes: 3 additions & 1 deletion datashader/tests/test_transfer_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import xarray as xr
import PIL
import pytest
import datashader.transfer_functions as tf
from datashader.tests.test_pandas import assert_eq_ndarray, assert_eq_xr, assert_image_close
Expand Down Expand Up @@ -1131,11 +1130,14 @@ def test_eq_hist(rng):


def test_Image_to_pil():
PIL = pytest.importorskip('PIL')
img = img1.to_pil()
assert isinstance(img, PIL.Image.Image)


def test_Image_to_bytesio():
pytest.importorskip('PIL')

bytes = img1.to_bytesio()
assert isinstance(bytes, BytesIO)
assert bytes.tell() == 0
Expand Down
6 changes: 5 additions & 1 deletion datashader/tiles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations
from importlib.util import find_spec
from io import BytesIO

import math
Expand All @@ -7,7 +8,6 @@

import numpy as np

from PIL.Image import fromarray
try:
import dask
import dask.bag as db
Expand Down Expand Up @@ -299,11 +299,15 @@ def __init__(self, tile_definition, output_location, tile_format='PNG',
self.tile_format = tile_format
self.post_render_func = post_render_func

if find_spec("PIL") is None:
raise ImportError('pillow is required to render tiles')
# TODO: add all the formats supported by PIL
if self.tile_format not in ('PNG', 'JPG'):
raise ValueError('Invalid output format')

def render(self, da, level):
from PIL.Image import fromarray

xmin, xmax = self.tile_def.x_range
ymin, ymax = self.tile_def.y_range
extent = xmin, ymin, xmax, ymax
Expand Down
3 changes: 2 additions & 1 deletion datashader/transfer_functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import numba as nb
import toolz as tz
import xarray as xr
from PIL.Image import fromarray

from datashader.colors import rgb, Sets1to3
from datashader.utils import nansum_missing, ngjit
Expand All @@ -34,6 +33,8 @@ class Image(xr.DataArray):
border=1

def to_pil(self, origin='lower'):
from PIL.Image import fromarray

data = self.data
if cupy:
data = cupy.asnumpy(data)
Expand Down
5 changes: 3 additions & 2 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ multipledispatch = "*"
numpy = "*"
pandas = "*"
param = "*"
pillow = "*"
pip = "*"
pyct = "*"
requests = "*"
Expand Down Expand Up @@ -68,7 +67,8 @@ holoviews = "*"
matplotlib-base = ">=3.3"
networkx = "*"
panel = ">1.1"
pyogrio = "*"
pillow = "*"
pyogrio = "*"
pyproj = "*"
python-graphviz = "*"
python-snappy = "*"
Expand Down Expand Up @@ -102,6 +102,7 @@ geodatasets = "*"
geopandas-base = "*"
netcdf4 = "*"
pyarrow = "*"
pillow = "*"
pyogrio = "*"
rasterio = "!=1.4.0" # 2024-11: Errors and will not solve to latest on Linux + Python 3.9
rioxarray = "*"
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ dependencies = [
'numpy',
'pandas',
'param',
'pillow',
'pyct',
'requests',
'scipy',
Expand Down