コード例 #1
0
ファイル: simple_rn.py プロジェクト: yochju/odl
# odl.diagnostics.SpaceTest(r5).run_tests()

# Do some tests to compare
n = 10**7
iterations = 10

# Perform some benchmarks with rn
opt_spc = odl.rn(n)
simple_spc = SimpleRn(n)

x, y, z = np.random.rand(n), np.random.rand(n), np.random.rand(n)
ox, oy, oz = (opt_spc.element(x.copy()), opt_spc.element(y.copy()),
              opt_spc.element(z.copy()))
sx, sy, sz = (simple_spc.element(x.copy()), simple_spc.element(y.copy()),
              simple_spc.element(z.copy()))
if 'cuda' in odl.fn_impl_names():
    cu_spc = odl.rn(n, impl='cuda')
    cx, cy, cz = (cu_spc.element(x.copy()), cu_spc.element(y.copy()),
                  cu_spc.element(z.copy()))

print(" lincomb:")
with Timer("SimpleRn"):
    for _ in range(iterations):
        simple_spc.lincomb(2.13, sx, 3.14, sy, out=sz)
print("result: {}".format(sz[1:5]))

with Timer("odl numpy"):
    for _ in range(iterations):
        opt_spc.lincomb(2.13, ox, 3.14, oy, out=oz)
print("result: {}".format(oz[1:5]))
コード例 #2
0
ファイル: pytest_plugins.py プロジェクト: yochju/odl
        os.path.join(odl_root, 'odl', 'trafos', 'wavelet.py'))


# Remove duplicates
collect_ignore = list(set(collect_ignore))
collect_ignore = [os.path.normcase(ignored) for ignored in collect_ignore]


def pytest_ignore_collect(path, config):
    normalized = os.path.normcase(str(path))
    return any(normalized.startswith(ignored) for ignored in collect_ignore)


# --- Reusable fixtures ---

fn_impl_params = odl.fn_impl_names()
fn_impl_ids = [" impl='{}' ".format(p) for p in fn_impl_params]


@fixture(scope="module", ids=fn_impl_ids, params=fn_impl_params)
def fn_impl(request):
    """String with an available `FnBase` implementation name."""
    return request.param


ntuples_impl_params = odl.ntuples_impl_names()
ntuples_impl_ids = [" impl='{}' ".format(p) for p in ntuples_impl_params]


@fixture(scope="module", ids=ntuples_impl_ids, params=ntuples_impl_params)
def ntuples_impl(request):