From 099a851538a2c7907196a3e59a1e3a3ee2a593d7 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Thu, 1 Jun 2017 22:41:09 -0400 Subject: [PATCH] cltypes: Rename types,type_to_scalar_and_count -> vec_... --- pyopencl/array.py | 6 ++++++ pyopencl/cltypes.py | 18 +++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pyopencl/array.py b/pyopencl/array.py index 9ee94a15..08f7cc8b 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -69,6 +69,12 @@ class VecLookupWarner(object): warn("pyopencl.array.vec is deprecated. " "Please use pyopencl.cltypes for OpenCL vector and scalar types", DeprecationWarning, 2) + + if name == "types": + name = "vec_types" + elif name == "type_to_scalar_and_count": + name = "vec_type_to_scalar_and_count" + return getattr(cltypes, name) diff --git a/pyopencl/cltypes.py b/pyopencl/cltypes.py index c8ff35c3..d1ba79f3 100644 --- a/pyopencl/cltypes.py +++ b/pyopencl/cltypes.py @@ -46,7 +46,6 @@ double = np.float64 # {{{ vector types - def _create_vector_types(): _mapping = [(k, globals()[k]) for k in ['char', 'uchar', 'short', 'ushort', 'int', @@ -55,10 +54,10 @@ def _create_vector_types(): def set_global(key, val): globals()[key] = val - field_names = ["x", "y", "z", "w"] + vec_types = {} + vec_type_to_scalar_and_count = {} - set_global('types', {}) - set_global('type_to_scalar_and_count', {}) + field_names = ["x", "y", "z", "w"] counts = [2, 3, 4, 8, 16] @@ -119,9 +118,14 @@ def _create_vector_types(): set_global("zeros_" + name, eval("lambda: filled_%s(0)" % (name))) set_global("ones_" + name, eval("lambda: filled_%s(1)" % (name))) - globals()['types'][np.dtype(base_type), count] = dtype - globals()['type_to_scalar_and_count'][dtype] = np.dtype(base_type), count + vec_types[np.dtype(base_type), count] = dtype + vec_type_to_scalar_and_count[dtype] = np.dtype(base_type), count + return vec_types, vec_type_to_scalar_and_count + + +vec_types, vec_type_to_scalar_and_count = _create_vector_types() -_create_vector_types() # }}} + +# vim: foldmethod=marker -- GitLab