diff --git a/holoviews/operation/datashader.py b/holoviews/operation/datashader.py index 808edb9b9d..e062c8342c 100644 --- a/holoviews/operation/datashader.py +++ b/holoviews/operation/datashader.py @@ -420,15 +420,19 @@ def get_agg_data(cls, obj, category=None): is_custom = isinstance(df, dd.DataFrame) or cuDFInterface.applies(df) if any((not is_custom and len(df[d.name]) and isinstance(df[d.name].values[0], cftime_types)) or - df[d.name].dtype.kind == 'M' for d in (x, y)): + df[d.name].dtype.kind in ["M", "u"] for d in (x, y)): df = df.copy() for d in (x, y): vals = df[d.name] if not is_custom and len(vals) and isinstance(vals.values[0], cftime_types): vals = cftime_to_timestamp(vals, 'ns') - elif df[d.name].dtype.kind == 'M': + elif vals.dtype.kind == 'M': vals = vals.astype('datetime64[ns]') + elif vals.dtype == np.uint64: + raise TypeError(f"Dtype of uint64 for column {d.name} is not supported.") + elif vals.dtype.kind == 'u': + pass # To convert to int64 else: continue df[d.name] = vals.astype('int64') diff --git a/holoviews/tests/operation/test_datashader.py b/holoviews/tests/operation/test_datashader.py index 67366025d9..0667da2617 100644 --- a/holoviews/tests/operation/test_datashader.py +++ b/holoviews/tests/operation/test_datashader.py @@ -3,6 +3,7 @@ from unittest import SkipTest, skipIf import numpy as np +import pytest from holoviews import ( Dimension, Curve, Points, Image, Dataset, RGB, Path, Graph, TriMesh, @@ -848,8 +849,6 @@ def test_regrid_upsampling(self): self.assertEqual(regridded, expected) def test_regrid_upsampling_linear(self): - ### This test causes a numba error using 0.35.0 - temporarily disabled ### - return img = Image(([0.5, 1.5], [0.5, 1.5], [[0, 1], [2, 3]])) regridded = regrid(img, width=4, height=4, upsample=True, interpolation='linear', dynamic=False) expected = Image(([0.25, 0.75, 1.25, 1.75], [0.25, 0.75, 1.25, 1.75], @@ -1322,3 +1321,18 @@ def test_polys_inspection_1px_mask_miss(self): polys = inspect_polygons(self.polysrgb, max_indicators=3, dynamic=False, pixels=1, x=0, y=0) self.assertEqual(polys, Polygons([], vdims='z')) + + +@pytest.mark.parametrize("dtype", [np.uint8, np.uint16, np.uint32]) +def test_uint_dtype(dtype): + df = pd.DataFrame(np.arange(2, dtype=dtype), columns=["A"]) + curve = Curve(df) + img = rasterize(curve, dynamic=False, height=10, width=10) + assert (np.asarray(img.data["Count"]) == np.eye(10)).all() + + +def test_uint64_dtype(): + df = pd.DataFrame(np.arange(2, dtype=np.uint64), columns=["A"]) + curve = Curve(df) + with pytest.raises(TypeError, match="Dtype of uint64 for column A is not supported."): + rasterize(curve, dynamic=False, height=10, width=10)