Skip to content

Commit

Permalink
Consistent test_gpu flag (#1132)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthomas23 committed Oct 11, 2022
1 parent 3817f88 commit 7b8aad8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
11 changes: 3 additions & 8 deletions datashader/tests/benchmarks/test_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

import datashader as ds

if "DATASHADER_TEST_GPU" in os.environ:
test_gpu = bool(int(os.environ["DATASHADER_TEST_GPU"]))
else:
test_gpu = None
test_gpu = bool(int(os.getenv("DATASHADER_TEST_GPU", 0)))


@pytest.fixture
Expand All @@ -35,8 +32,7 @@ def test_points(benchmark, time_series):
benchmark(cvs.points, time_series, 'x', 'y')


@pytest.mark.skipif(test_gpu is None, reason="DATASHADER_TEST_GPU not in environment")
@pytest.mark.skipif(test_gpu is False, reason="DATASHADER_TEST_GPU is set to False")
@pytest.mark.skipif(not test_gpu, reason="DATASHADER_TEST_GPU not set")
@pytest.mark.benchmark(group="canvas")
def test_line_gpu(benchmark, time_series):
from cudf import from_pandas
Expand All @@ -45,8 +41,7 @@ def test_line_gpu(benchmark, time_series):
benchmark(cvs.line, time_series, 'x', 'y')


@pytest.mark.skipif(test_gpu is None, reason="DATASHADER_TEST_GPU not in environment")
@pytest.mark.skipif(test_gpu is False, reason="DATASHADER_TEST_GPU is set to False")
@pytest.mark.skipif(not test_gpu, reason="DATASHADER_TEST_GPU not set")
@pytest.mark.benchmark(group="canvas")
def test_points_gpu(benchmark, time_series):
from cudf import from_pandas
Expand Down
9 changes: 3 additions & 6 deletions datashader/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@

config.set(scheduler='synchronous')

if "DATASHADER_TEST_GPU" in os.environ:
test_gpu = bool(int(os.environ["DATASHADER_TEST_GPU"]))
else:
test_gpu = None
test_gpu = bool(int(os.getenv("DATASHADER_TEST_GPU", 0)))

df_pd = pd.DataFrame({'x': np.array(([0.] * 10 + [1] * 10)),
'y': np.array(([0.] * 5 + [1] * 5 + [0] * 5 + [1] * 5)),
Expand Down Expand Up @@ -62,7 +59,7 @@ def dask_DataFrame(*args, **kwargs):
import cupy
import dask_cudf

if test_gpu is False:
if not test_gpu:
# GPU testing disabled even though cudf/cupy are available
raise ImportError

Expand Down Expand Up @@ -109,7 +106,7 @@ def floats(n):


def test_gpu_dependencies():
if test_gpu is True and cudf is None:
if test_gpu and cudf is None:
pytest.fail(
"cudf, cupy, and/or dask_cudf not available and DATASHADER_TEST_GPU=1"
)
Expand Down
10 changes: 3 additions & 7 deletions datashader/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
df_pd.at[2,'f64'] = nan
dfs_pd = [df_pd]

if "DATASHADER_TEST_GPU" in os.environ:
test_gpu = bool(int(os.environ["DATASHADER_TEST_GPU"]))
else:
test_gpu = None
test_gpu = bool(int(os.getenv("DATASHADER_TEST_GPU", 0)))


try:
Expand Down Expand Up @@ -135,12 +132,11 @@ def values(s):


def test_gpu_dependencies():
if test_gpu is True and cudf is None:
if test_gpu and cudf is None:
pytest.fail("cudf and/or cupy not available and DATASHADER_TEST_GPU=1")


@pytest.mark.skipif(test_gpu is None, reason="DATASHADER_TEST_GPU not in environment")
@pytest.mark.skipif(test_gpu is False, reason="DATASHADER_TEST_GPU is set to False")
@pytest.mark.skipif(not test_gpu, reason="DATASHADER_TEST_GPU not set")
def test_cudf_concat():
# Testing if a newer version of cuDF implements the possibility to
# concatenate multiple columns with the same name.
Expand Down

0 comments on commit 7b8aad8

Please sign in to comment.