From 2069e366014e29bb1522018b634797444a9ef79f Mon Sep 17 00:00:00 2001 From: Marko Bencun <mbencun@gmail.com> Date: Fri, 6 Sep 2013 19:47:51 +0200 Subject: [PATCH] re-export numpy so we can use numpypy --- pyopencl/__init__.py | 5 +---- pyopencl/algorithm.py | 2 +- pyopencl/array.py | 2 +- pyopencl/capture_call.py | 4 ++-- pyopencl/characterize/performance.py | 2 +- pyopencl/clrandom.py | 2 +- pyopencl/elementwise.py | 2 +- pyopencl/np.py | 4 ++++ pyopencl/reduction.py | 2 +- pyopencl/scan.py | 2 +- pyopencl/tools.py | 4 ++-- 11 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 pyopencl/np.py diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index 601ec6f9..704dd7b4 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -38,10 +38,7 @@ except ImportError: # _ccl = _cl # import cffi_cl # _cl = cffi_cl -try: - import numpypy as np -except: - import numpy as np +import np #from pyopencl._cl import * # noqa from pyopencl.cffi_cl import * import inspect as _inspect diff --git a/pyopencl/algorithm.py b/pyopencl/algorithm.py index 2ad82f7b..e34bb018 100644 --- a/pyopencl/algorithm.py +++ b/pyopencl/algorithm.py @@ -27,7 +27,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -import numpy as np +import pyopencl.np as np import pyopencl as cl import pyopencl.array # noqa from pyopencl.scan import ScanTemplate diff --git a/pyopencl/array.py b/pyopencl/array.py index 2877ac56..2bc18d54 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE. """ -import numpy as np +import pyopencl.np as np import pyopencl.elementwise as elementwise import pyopencl as cl from pytools import memoize_method diff --git a/pyopencl/capture_call.py b/pyopencl/capture_call.py index b45e3102..1d6b2e2f 100644 --- a/pyopencl/capture_call.py +++ b/pyopencl/capture_call.py @@ -24,7 +24,7 @@ THE SOFTWARE. import pyopencl as cl -import numpy as np +import pyopencl.np as np from pytools.py_codegen import PythonCodeGenerator, Indentation @@ -41,7 +41,7 @@ def capture_kernel_call(kernel, filename, queue, g_size, l_size, *args, **kwargs cg("# generated by pyopencl.capture_call") cg("") - cg("import numpy as np") + cg("import pyopencl.np as np") cg("import pyopencl as cl") cg("from base64 import b64decode") cg("from zlib import decompress") diff --git a/pyopencl/characterize/performance.py b/pyopencl/characterize/performance.py index e498582e..2b843877 100644 --- a/pyopencl/characterize/performance.py +++ b/pyopencl/characterize/performance.py @@ -23,7 +23,7 @@ THE SOFTWARE. """ import pyopencl as cl -import numpy as np +import pyopencl.np as np diff --git a/pyopencl/clrandom.py b/pyopencl/clrandom.py index 92a5c2de..03d5494f 100644 --- a/pyopencl/clrandom.py +++ b/pyopencl/clrandom.py @@ -57,7 +57,7 @@ import pyopencl.array as cl_array from pyopencl.tools import first_arg_dependent_memoize from pytools import memoize_method -import numpy as np +import pyopencl.np as np class RanluxGenerator(object): diff --git a/pyopencl/elementwise.py b/pyopencl/elementwise.py index 5878b89c..36d127fd 100644 --- a/pyopencl/elementwise.py +++ b/pyopencl/elementwise.py @@ -29,7 +29,7 @@ OTHER DEALINGS IN THE SOFTWARE. from pyopencl.tools import context_dependent_memoize -import numpy as np +import pyopencl.np as np import pyopencl as cl from pytools import memoize_method from pyopencl.tools import (dtype_to_ctype, VectorArg, ScalarArg, diff --git a/pyopencl/np.py b/pyopencl/np.py new file mode 100644 index 00000000..1c35453e --- /dev/null +++ b/pyopencl/np.py @@ -0,0 +1,4 @@ +try: + from numpypy import * +except ImportError: + from numpy import * diff --git a/pyopencl/reduction.py b/pyopencl/reduction.py index f342909f..60d8b17f 100644 --- a/pyopencl/reduction.py +++ b/pyopencl/reduction.py @@ -36,7 +36,7 @@ from pyopencl.tools import ( context_dependent_memoize, dtype_to_ctype, KernelTemplateBase, _process_code_for_macro) -import numpy as np +import pyopencl.np as np # {{{ kernel source diff --git a/pyopencl/scan.py b/pyopencl/scan.py index 2d7bc9ec..38233f96 100644 --- a/pyopencl/scan.py +++ b/pyopencl/scan.py @@ -28,7 +28,7 @@ within the Thrust project, https://code.google.com/p/thrust/ # Direct link to thrust source: # https://code.google.com/p/thrust/source/browse/thrust/detail/backend/cuda/detail/fast_scan.inl # noqa -import numpy as np +import pyopencl.np as np import pyopencl as cl import pyopencl.array # noqa diff --git a/pyopencl/tools.py b/pyopencl/tools.py index 47c00140..553eb064 100644 --- a/pyopencl/tools.py +++ b/pyopencl/tools.py @@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE. """ -import numpy as np +import pyopencl.np as np from decorator import decorator import pyopencl as cl from pytools import memoize, memoize_method @@ -524,7 +524,7 @@ def match_dtype_to_c_struct(device, name, dtype, context=None): This example explains the use of this function:: - >>> import numpy as np + >>> import pyopencl.np as np >>> import pyopencl as cl >>> import pyopencl.tools >>> ctx = cl.create_some_context() -- GitLab