Skip to content

Commit 309855a

Browse files
committed
BUG: fix impl check in RayTransform
1 parent 577b516 commit 309855a

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

odl/tomo/operators/ray_trafo.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2014-2018 The ODL contributors
1+
# Copyright 2014-2019 The ODL contributors
22
#
33
# This file is part of ODL.
44
#
@@ -145,20 +145,30 @@ def __init__(self, reco_space, geometry, variant, **kwargs):
145145
else:
146146
raise RuntimeError('bad impl')
147147

148-
impl, impl_in = str(impl).lower(), impl
149-
if impl not in _SUPPORTED_IMPL:
150-
raise ValueError('`impl` {!r} not understood'.format(impl_in))
151-
if impl not in _AVAILABLE_IMPLS:
152-
raise ValueError('{!r} back-end not available'.format(impl))
148+
impl_in = None
149+
150+
else:
151+
impl, impl_in = str(impl).lower(), impl
152+
if impl not in _SUPPORTED_IMPL:
153+
raise ValueError('`impl` {!r} not understood'.format(impl_in))
154+
if impl not in _AVAILABLE_IMPLS:
155+
raise ValueError('{!r} back-end not available'.format(impl))
153156

154157
# Cache for input/output arrays of transforms
155158
self.use_cache = kwargs.pop('use_cache', True)
156159

157160
# Sanity checks
158161
if impl.startswith('astra'):
159162
if geometry.ndim > 2 and impl.endswith('cpu'):
160-
raise ValueError('`impl` {!r} only works for 2d'
161-
''.format(impl_in))
163+
if impl_in is None:
164+
raise ValueError(
165+
'fastest available `impl` {!r} only supports 2D'
166+
''.format(impl)
167+
)
168+
else:
169+
raise ValueError(
170+
'`impl` {!r} only supports 2D'.format(impl_in)
171+
)
162172

163173
# Print a warning if the detector midpoint normal vector at any
164174
# angle is perpendicular to the geometry axis in parallel 3d

0 commit comments

Comments
 (0)