From 2c9486ffb15da0c28afbe388ab8666044ed1f8de Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Wed, 27 Dec 2017 17:28:46 -0600 Subject: [PATCH] Improve error reporting in to_loopy_type for allow_{auto,none}=False --- loopy/types.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/loopy/types.py b/loopy/types.py index f095d1d58..8f0f310c3 100644 --- a/loopy/types.py +++ b/loopy/types.py @@ -177,13 +177,20 @@ class AtomicNumpyType(NumpyType, AtomicType): # }}} -def to_loopy_type(dtype, allow_none=False, allow_auto=False, for_atomic=False, +def to_loopy_type(dtype, allow_auto=False, allow_none=False, for_atomic=False, target=None): from loopy.kernel.data import auto - if allow_none and dtype is None: - return dtype - elif allow_auto and dtype is auto: - return dtype + if dtype is None: + if allow_none: + return None + else: + raise LoopyError("dtype may not be none") + + elif dtype is auto: + if allow_auto: + return dtype + else: + raise LoopyError("dtype may not be auto") numpy_dtype = None -- GitLab