Skip to content

Commit

Permalink
Update test_xarray
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed May 24, 2024
1 parent a4a5f39 commit 00d7bda
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions datashader/tests/test_xarray.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
from copy import deepcopy
import numpy as np
from numpy import nan
import os
import xarray as xr

import datashader as ds
Expand All @@ -14,9 +14,6 @@
except ImportError:
cupy = None

test_gpu = bool(int(os.getenv("DATASHADER_TEST_GPU", 0)))


xda = xr.DataArray(data=np.array(([1.] * 10 + [10] * 10)),
dims=('record'),
coords={'x': xr.DataArray(np.array(([0.]*10 + [1]*10)), dims=('record')),
Expand Down Expand Up @@ -46,9 +43,7 @@ def assert_eq(agg, b):
assert agg.equals(b)


@pytest.mark.parametrize("source", [
(xda), (xdda), (xds), (xdds),
])
@pytest.mark.parametrize("source", [xda, xdda, xds, xdds])
def test_count(source):
out = xr.DataArray(np.array([[5, 5], [5, 5]], dtype='i4'),
coords=coords, dims=dims)
Expand Down Expand Up @@ -97,20 +92,18 @@ def test_count(source):


@pytest.mark.parametrize("ds2d", ds2ds)
@pytest.mark.parametrize("cuda", [False, True])
@pytest.mark.parametrize('on_gpu', [False, pytest.param(True, marks=pytest.mark.gpu)])
@pytest.mark.parametrize("chunksizes", [
None,
dict(x=10, channel=10),
dict(x=10, channel=1),
dict(x=3, channel=10),
dict(x=3, channel=1),
])
def test_lines_xarray_common_x(ds2d, cuda, chunksizes):
source = ds2d.copy()
if cuda:
if not (cupy and test_gpu):
pytest.skip("CUDA tests not requested")
elif chunksizes is not None:
def test_lines_xarray_common_x(ds2d, on_gpu, chunksizes):
source = deepcopy(ds2d)
if on_gpu:
if chunksizes is not None:

Check warning on line 106 in datashader/tests/test_xarray.py

View check run for this annotation

Codecov / codecov/patch

datashader/tests/test_xarray.py#L106

Added line #L106 was not covered by tests
pytest.skip("CUDA-dask for LinesXarrayCommonX not implemented")

# CPU -> GPU
Expand Down Expand Up @@ -162,7 +155,7 @@ def test_lines_xarray_common_x(ds2d, cuda, chunksizes):
assert_eq_ndarray(agg.x_range, (0, 4), close=True)
assert_eq_ndarray(agg.y_range, (0, 2), close=True)
assert_eq_ndarray(agg.data, sol_count)
assert isinstance(agg.data, cupy.ndarray if cuda else np.ndarray)
assert isinstance(agg.data, cupy.ndarray if on_gpu else np.ndarray)

# any
agg = canvas.line(source, x="x", y="name", agg=ds.any())
Expand Down

0 comments on commit 00d7bda

Please sign in to comment.