Пример #1
0
from __future__ import division
import pytest
import numpy as np

import odl
from odl.util.testutils import almost_equal, never_skip

skip_if_no_pyfftw = pytest.mark.skipif("not odl.trafos.PYFFTW_AVAILABLE",
                                       reason='pyfftw not available')
pytestmark = odl.util.skip_if_no_largescale


# --- pytest fixtures --- #


impl_params = [never_skip('numpy'), skip_if_no_pyfftw('pyfftw')]
impl_ids = [" impl = '{}'".format(p.args[1]) for p in impl_params]


# bug in pytest (ignores pytestmark) forces us to do this this
largescale = " or not pytest.config.getoption('--largescale')"
impl_params = [pytest.mark.skipif(p.args[0] + largescale, p.args[1])
               for p in impl_params]


@pytest.fixture(scope="module", ids=impl_ids, params=impl_params)
def impl(request):
    return request.param


dom_params = [odl.uniform_discr(-2, 2, 10 ** 5),
Пример #2
0
@pytest.fixture(scope="module", params=methods, ids=method_ids)
def method(request):
    return request.param


paddings = [('constant', 0), ('constant', 1), 'symmetric', 'periodic']
padding_ids = [' constant=0 ', ' constant=1 ', ' symmetric ', ' periodic ']


@pytest.fixture(scope="module", params=paddings, ids=padding_ids)
def padding(request):
    return request.param


# Find the valid projectors
impls = [never_skip('numpy'),
         skip_if_no_cuda('cuda')]
impl_ids = [' impl={} '.format(p.args[1]) for p in impls]


@pytest.fixture(scope="module", params=impls, ids=impl_ids)
def impl(request):
    return request.param


# Test data
DATA_1D = np.array([0.5, 1, 3.5, 2, -.5, 3, -1, -1, 0, 3])
DATA_2D = np.array([[0., 1., 2., 3., 4.],
                    [1., 2., 3., 4., 5.],
                    [2., 3., 4., 5., 6.]])
Пример #3
0
# External module imports
import pytest
import numpy as np

# ODL imports
import odl
from odl.util.testutils import almost_equal, never_skip

skip_if_no_pyfftw = pytest.mark.skipif("not odl.trafos.PYFFTW_AVAILABLE",
                                       reason='pyfftw not available')
pytestmark = odl.util.skip_if_no_largescale


# Pytest fixtures
impl_params = [never_skip('numpy'), skip_if_no_pyfftw('pyfftw')]
impl_ids = [" impl = '{}'".format(p.args[1]) for p in impl_params]


# bug in pytest (ignores pytestmark) forces us to do this this
largescale = " or not pytest.config.getoption('--largescale')"
impl_params = [pytest.mark.skipif(p.args[0] + largescale, p.args[1])
               for p in impl_params]


@pytest.fixture(scope="module", ids=impl_ids, params=impl_params)
def impl(request):
    return request.param


dom_params = [odl.uniform_discr(-2, 2, 10 ** 5),
Пример #4
0
standard_library.install_aliases()

# External module imports
import pytest
import numpy as np

# ODL imports
import odl
from odl.util.testutils import (all_almost_equal, almost_equal, never_skip,
                                skip_if_no_cuda, example_vectors)

pytestmark = odl.util.skip_if_no_largescale

# Pytest fixtures
spc_params = [
    never_skip('fn numpy float32'),
    never_skip('fn numpy float64'),
    never_skip('fn numpy complex64'),
    never_skip('fn numpy complex128'),
    never_skip('1d numpy float32'),
    never_skip('1d numpy float64'),
    never_skip('1d numpy complex64'),
    never_skip('1d numpy complex128'),
    never_skip('3d numpy float32'),
    never_skip('3d numpy float64'),
    never_skip('3d numpy complex64'),
    never_skip('3d numpy complex128'),
    skip_if_no_cuda('fn cuda float32'),
    skip_if_no_cuda('1d cuda float32'),
    skip_if_no_cuda('3d cuda float32')
]
Пример #5
0
standard_library.install_aliases()

# External module imports
import pytest
import numpy as np

# ODL imports
import odl
from odl.util.testutils import (all_almost_equal, almost_equal,
                                never_skip, skip_if_no_cuda, example_vectors)

pytestmark = odl.util.skip_if_no_largescale


# Pytest fixtures
spc_params = [never_skip('fn numpy float32'),
              never_skip('fn numpy float64'),
              never_skip('fn numpy complex64'),
              never_skip('fn numpy complex128'),
              never_skip('1d numpy float32'),
              never_skip('1d numpy float64'),
              never_skip('1d numpy complex64'),
              never_skip('1d numpy complex128'),
              never_skip('3d numpy float32'),
              never_skip('3d numpy float64'),
              never_skip('3d numpy complex64'),
              never_skip('3d numpy complex128'),
              skip_if_no_cuda('fn cuda float32'),
              skip_if_no_cuda('1d cuda float32'),
              skip_if_no_cuda('3d cuda float32')]
Пример #6
0
                                never_skip, skip_if_no_cuda, example_vectors)

# Pytest fixture


# Simply modify exp_params to modify the fixture
exp_params = [2.0, 1.0, float('inf'), 0.5, 1.5]
exp_ids = [' p = {} '.format(p) for p in exp_params]


@pytest.fixture(scope="module", ids=exp_ids, params=exp_params)
def exponent(request):
    return request.param


impl_params = [never_skip('numpy'),
               skip_if_no_cuda('cuda')]
impl_ids = [' impl = {} '.format(p.args[1]) for p in impl_params]


@pytest.fixture(scope="module", ids=impl_ids, params=impl_params)
def impl(request):
    return request.param


def test_init(exponent):
    # Validate that the different init patterns work and do not crash.
    space = odl.FunctionSpace(odl.Interval(0, 1))
    part = odl.uniform_partition_fromintv(space.domain, 10)
    rn = odl.Rn(10, exponent=exponent)
    odl.DiscreteLp(space, part, rn, exponent=exponent)
Пример #7
0
standard_library.install_aliases()

# External module imports
import pytest
import numpy as np

# ODL imports
import odl
from odl.util.testutils import (all_almost_equal, almost_equal,
                                never_skip, skip_if_no_cuda, example_vectors)

pytestmark = odl.util.skip_if_no_largescale


# Pytest fixtures
spc_params = [never_skip('rn numpy'),
              never_skip('1d numpy'),
              never_skip('3d numpy'),
              skip_if_no_cuda('rn cuda'),
              skip_if_no_cuda('1d cuda'),
              skip_if_no_cuda('3d cuda')]


spc_ids = [' type={} impl={}'
           ''.format(*p.args[1].split()) for p in spc_params]


# bug in pytest (ignores pytestmark) forces us to do this this
largescale = " or not pytest.config.getoption('--largescale')"
spc_params = [pytest.mark.skipif(p.args[0] + largescale, p.args[1])
              for p in spc_params]
Пример #8
0
                                never_skip, skip_if_no_cuda, example_vectors)

# Pytest fixture


# Simply modify exp_params to modify the fixture
exp_params = [2.0, 1.0, float('inf'), 0.5, 1.5]
exp_ids = [' p = {} '.format(p) for p in exp_params]


@pytest.fixture(scope="module", ids=exp_ids, params=exp_params)
def exponent(request):
    return request.param


impl_params = [never_skip('numpy'),
               skip_if_no_cuda('cuda')]
impl_ids = [' impl = {} '.format(p.args[1]) for p in impl_params]


@pytest.fixture(scope="module", ids=impl_ids, params=impl_params)
def impl(request):
    return request.param


def test_init(exponent):
    # Validate that the different init patterns work and do not crash.
    space = odl.FunctionSpace(odl.Interval(0, 1))
    part = odl.uniform_partition_fromintv(space.domain, 10)
    rn = odl.Rn(10, exponent=exponent)
    odl.DiscreteLp(space, part, rn, exponent=exponent)