From 2ad3ee4ed69484ecc3e7e231be1bb1d44b6dae22 Mon Sep 17 00:00:00 2001 From: arghdos Date: Fri, 9 Dec 2016 12:02:46 -0500 Subject: [PATCH 1/2] allow passing of a regular numpy dtype in --- loopy/kernel/data.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/loopy/kernel/data.py b/loopy/kernel/data.py index 5195e0a10..3d49ebf76 100644 --- a/loopy/kernel/data.py +++ b/loopy/kernel/data.py @@ -379,10 +379,13 @@ class TemporaryVariable(ArrayBase): "offset must be 0 if initializer specified" % name) + from loopy.types import NumpyType if dtype is auto or dtype is None: - from loopy.types import NumpyType dtype = NumpyType(initializer.dtype) - elif dtype.numpy_dtype != initializer.dtype: + elif ((isinstance(dtype, NumpyType) and + dtype.numpy_dtype != initializer.dtype) or + (isinstance(dtype, np.dtype) and + dtype != initializer.dtype)): raise LoopyError( "temporary variable '%s': " "dtype of initializer does not match " -- GitLab From 12081cb90629c3cf10044dd8026b68e612fcc880 Mon Sep 17 00:00:00 2001 From: arghdos Date: Fri, 9 Dec 2016 12:40:42 -0500 Subject: [PATCH 2/2] use to_loopy_type instead of manual comparison --- loopy/kernel/data.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/loopy/kernel/data.py b/loopy/kernel/data.py index 3d49ebf76..001dd0632 100644 --- a/loopy/kernel/data.py +++ b/loopy/kernel/data.py @@ -379,13 +379,10 @@ class TemporaryVariable(ArrayBase): "offset must be 0 if initializer specified" % name) - from loopy.types import NumpyType + from loopy.types import NumpyType, to_loopy_type if dtype is auto or dtype is None: dtype = NumpyType(initializer.dtype) - elif ((isinstance(dtype, NumpyType) and - dtype.numpy_dtype != initializer.dtype) or - (isinstance(dtype, np.dtype) and - dtype != initializer.dtype)): + elif to_loopy_type(dtype) != to_loopy_type(initializer.dtype): raise LoopyError( "temporary variable '%s': " "dtype of initializer does not match " -- GitLab