From 01a56d31d5249f9a743cb4cdbe043283158576d0 Mon Sep 17 00:00:00 2001 From: Michael Kuron <mkuron@icp.uni-stuttgart.de> Date: Wed, 22 Jan 2020 12:06:11 +0100 Subject: [PATCH] skip tests with unmet dependencies --- conftest.py | 19 +++++++++++++++++-- pystencils/kernelcreation.py | 4 ++-- pystencils_tests/test_custom_backends.py | 13 +++++++++++-- pystencils_tests/test_interpolation.py | 8 ++++++-- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/conftest.py b/conftest.py index c20bde409..78164d005 100644 --- a/conftest.py +++ b/conftest.py @@ -44,7 +44,7 @@ collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils/autodiff.py")] try: import pycuda except ImportError: - collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils/pystencils_tests/test_cudagpu.py")] + collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils_tests/test_cudagpu.py")] add_path_to_ignore('pystencils/gpucuda') try: @@ -73,7 +73,22 @@ try: import blitzdb except ImportError: add_path_to_ignore('pystencils/runhelper') + collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils_tests/test_parameterstudy.py")] +try: + import islpy +except ImportError: + collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils/integer_set_analysis.py")] + +try: + import graphviz +except ImportError: + collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils/backends/dot.py")] + +try: + import pyevtk +except ImportError: + collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils/datahandling/vtk.py")] collect_ignore += [os.path.join(SCRIPT_FOLDER, 'setup.py')] @@ -131,7 +146,7 @@ class IPyNbFile(pytest.File): exporter.exclude_markdown = True exporter.exclude_input_prompt = True - notebook_contents = self.fspath.open() + notebook_contents = self.fspath.open(encoding='utf-8') with warnings.catch_warnings(): warnings.filterwarnings("ignore", "IPython.core.inputsplitter is deprecated") diff --git a/pystencils/kernelcreation.py b/pystencils/kernelcreation.py index aaca6d312..2c8aabaa5 100644 --- a/pystencils/kernelcreation.py +++ b/pystencils/kernelcreation.py @@ -79,14 +79,14 @@ def create_kernel(assignments, [0., 0., 0., 0., 0.]]) """ # ---- Normalizing parameters + if isinstance(assignments, Assignment): + assignments = [assignments] assert assignments, "Assignments must not be empty!" split_groups = () if isinstance(assignments, AssignmentCollection): if 'split_groups' in assignments.simplification_hints: split_groups = assignments.simplification_hints['split_groups'] assignments = assignments.all_assignments - if isinstance(assignments, Assignment): - assignments = [assignments] # ---- Creating ast if target == 'cpu': diff --git a/pystencils_tests/test_custom_backends.py b/pystencils_tests/test_custom_backends.py index 1ff775d41..692f78894 100644 --- a/pystencils_tests/test_custom_backends.py +++ b/pystencils_tests/test_custom_backends.py @@ -1,6 +1,5 @@ from subprocess import CalledProcessError -import pycuda.driver import pytest import sympy @@ -25,7 +24,7 @@ class ScreamingGpuBackend(CudaBackend): return normal_code.upper() -def test_custom_backends(): +def test_custom_backends_cpu(): z, x, y = pystencils.fields("z, y, x: [2d]") normal_assignments = pystencils.AssignmentCollection([pystencils.Assignment( @@ -36,6 +35,16 @@ def test_custom_backends(): with pytest.raises(CalledProcessError): pystencils.cpu.cpujit.make_python_function(ast, custom_backend=ScreamingBackend()) + +def test_custom_backends_gpu(): + pytest.importorskip('pycuda') + import pycuda.driver + + z, x, y = pystencils.fields("z, y, x: [2d]") + + normal_assignments = pystencils.AssignmentCollection([pystencils.Assignment( + z[0, 0], x[0, 0] * sympy.log(x[0, 0] * y[0, 0]))], []) + ast = pystencils.create_kernel(normal_assignments, target='gpu') print(pystencils.show_code(ast, ScreamingGpuBackend())) with pytest.raises(pycuda.driver.CompileError): diff --git a/pystencils_tests/test_interpolation.py b/pystencils_tests/test_interpolation.py index dd4ee06f4..0776a7de0 100644 --- a/pystencils_tests/test_interpolation.py +++ b/pystencils_tests/test_interpolation.py @@ -11,8 +11,6 @@ import itertools from os.path import dirname, join import numpy as np -import pycuda.autoinit # NOQA -import pycuda.gpuarray as gpuarray import pytest import sympy @@ -112,6 +110,9 @@ def test_rotate_interpolation(address_mode): @pytest.mark.parametrize('address_mode', ['border', 'wrap', 'clamp', 'mirror']) def test_rotate_interpolation_gpu(address_mode): + pytest.importorskip('pycuda') + import pycuda.autoinit # NOQA + import pycuda.gpuarray as gpuarray rotation_angle = sympy.pi / 5 scale = 1 @@ -156,6 +157,9 @@ def test_rotate_interpolation_gpu(address_mode): @pytest.mark.parametrize('address_mode', ['border', 'wrap', 'clamp', 'mirror']) def test_shift_interpolation_gpu(address_mode): + pytest.importorskip('pycuda') + import pycuda.autoinit # NOQA + import pycuda.gpuarray as gpuarray rotation_angle = 0 # sympy.pi / 5 scale = 1 -- GitLab