[python-arrayfire] 94/250: STYLE: Use Python Enum instead of ctypes.c_int for enums

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:35 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository python-arrayfire.

commit c8ec23485d4265142060e6db1e946f52f7a7531d
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Tue Sep 1 18:58:32 2015 -0400

    STYLE: Use Python Enum instead of ctypes.c_int for enums
---
 arrayfire/arith.py     |  18 ++--
 arrayfire/array.py     |  57 +++++++------
 arrayfire/blas.py      |  14 ++--
 arrayfire/data.py      |  54 +++---------
 arrayfire/graphics.py  |   5 +-
 arrayfire/image.py     |  66 +++++++++------
 arrayfire/lapack.py    |  17 ++--
 arrayfire/library.py   | 221 ++++++++++++++++++++++++++-----------------------
 arrayfire/signal.py    |  42 ++++++----
 arrayfire/util.py      |  86 +++++++++----------
 arrayfire/vision.py    |   2 +-
 tests/simple_arith.py  |   6 +-
 tests/simple_blas.py   |   4 +-
 tests/simple_data.py   |  18 ++--
 tests/simple_image.py  |   2 +-
 tests/simple_index.py  |   2 +-
 tests/simple_lapack.py |   8 +-
 17 files changed, 318 insertions(+), 304 deletions(-)

diff --git a/arrayfire/arith.py b/arrayfire/arith.py
index 43fe6af..bdf5716 100644
--- a/arrayfire/arith.py
+++ b/arrayfire/arith.py
@@ -56,19 +56,25 @@ def cast(a, dtype):
     ----------
     a    : af.Array
            Multi dimensional arrayfire array.
-    dtype: ctypes.c_int.
+    dtype: af.Dtype
            Must be one of the following:
-           af.f32, af.f64, af.c32, af.c64
-           af.s32, af.s64, af.u32, af.u64,
-           af.b8, af.u8
-
+               - Dtype.f32 for float
+               - Dtype.f64 for double
+               - Dtype.b8  for bool
+               - Dtype.u8  for unsigned char
+               - Dtype.s32 for signed 32 bit integer
+               - Dtype.u32 for unsigned 32 bit integer
+               - Dtype.s64 for signed 64 bit integer
+               - Dtype.u64 for unsigned 64 bit integer
+               - Dtype.c32 for 32 bit complex number
+               - Dtype.c64 for 64 bit complex number
     Returns
     --------
     out  : af.Array
            array containing the values from `a` after converting to `dtype`.
     """
     out=Array()
-    safe_call(backend.get().af_cast(ct.pointer(out.arr), a.arr, dtype))
+    safe_call(backend.get().af_cast(ct.pointer(out.arr), a.arr, dtype.value))
     return out
 
 def minof(lhs, rhs):
diff --git a/arrayfire/array.py b/arrayfire/array.py
index f5ebe55..509d336 100644
--- a/arrayfire/array.py
+++ b/arrayfire/array.py
@@ -22,17 +22,17 @@ def _create_array(buf, numdims, idims, dtype):
     out_arr = ct.c_void_p(0)
     c_dims = dim4(idims[0], idims[1], idims[2], idims[3])
     safe_call(backend.get().af_create_array(ct.pointer(out_arr), ct.c_void_p(buf),
-                                            numdims, ct.pointer(c_dims), dtype))
+                                            numdims, ct.pointer(c_dims), dtype.value))
     return out_arr
 
 def _create_empty_array(numdims, idims, dtype):
     out_arr = ct.c_void_p(0)
     c_dims = dim4(idims[0], idims[1], idims[2], idims[3])
     safe_call(backend.get().af_create_handle(ct.pointer(out_arr),
-                                            numdims, ct.pointer(c_dims), dtype))
+                                             numdims, ct.pointer(c_dims), dtype.value))
     return out_arr
 
-def constant_array(val, d0, d1=None, d2=None, d3=None, dtype=f32):
+def constant_array(val, d0, d1=None, d2=None, d3=None, dtype=Dtype.f32):
     """
     Internal function to create a C array. Should not be used externall.
     """
@@ -40,6 +40,8 @@ def constant_array(val, d0, d1=None, d2=None, d3=None, dtype=f32):
     if not isinstance(dtype, ct.c_int):
         if isinstance(dtype, int):
             dtype = ct.c_int(dtype)
+        elif isinstance(dtype, Dtype):
+            dtype = ct.c_int(dtype.value)
         else:
             raise TypeError("Invalid dtype")
 
@@ -50,15 +52,15 @@ def constant_array(val, d0, d1=None, d2=None, d3=None, dtype=f32):
         c_real = ct.c_double(val.real)
         c_imag = ct.c_double(val.imag)
 
-        if (dtype != c32 and dtype != c64):
-            dtype = c32
+        if (dtype.value != Dtype.c32.value and dtype.value != Dtype.c64.value):
+            dtype = Dtype.c32.value
 
         safe_call(backend.get().af_constant_complex(ct.pointer(out), c_real, c_imag,
-                                           4, ct.pointer(dims), dtype))
-    elif dtype == s64:
+                                                    4, ct.pointer(dims), dtype))
+    elif dtype.value == Dtype.s64.value:
         c_val = ct.c_longlong(val.real)
         safe_call(backend.get().af_constant_long(ct.pointer(out), c_val, 4, ct.pointer(dims)))
-    elif dtype == u64:
+    elif dtype.value == Dtype.u64.value:
         c_val = ct.c_ulonglong(val.real)
         safe_call(backend.get().af_constant_ulong(ct.pointer(out), c_val, 4, ct.pointer(dims)))
     else:
@@ -76,7 +78,7 @@ def _binary_func(lhs, rhs, c_func):
         ldims = dim4_to_tuple(lhs.dims())
         rty = implicit_dtype(rhs, lhs.type())
         other = Array()
-        other.arr = constant_array(rhs, ldims[0], ldims[1], ldims[2], ldims[3], rty)
+        other.arr = constant_array(rhs, ldims[0], ldims[1], ldims[2], ldims[3], rty.value)
     elif not isinstance(rhs, Array):
         raise TypeError("Invalid parameter to binary function")
 
@@ -92,7 +94,7 @@ def _binary_funcr(lhs, rhs, c_func):
         rdims = dim4_to_tuple(rhs.dims())
         lty = implicit_dtype(lhs, rhs.type())
         other = Array()
-        other.arr = constant_array(lhs, rdims[0], rdims[1], rdims[2], rdims[3], lty)
+        other.arr = constant_array(lhs, rdims[0], rdims[1], rdims[2], rdims[3], lty.value)
     elif not isinstance(lhs, Array):
         raise TypeError("Invalid parameter to binary function")
 
@@ -186,7 +188,7 @@ class Array(BaseArray):
     dims : optional: tuple of ints. default: (0,)
          - When using the default values of `dims`, the dims are caclulated as `len(src)`
 
-    dtype: optional: str or ctypes.c_int. default: None.
+    dtype: optional: str or arrayfire.Dtype. default: None.
            - if str, must be one of the following:
                - 'f' for float
                - 'd' for double
@@ -198,18 +200,18 @@ class Array(BaseArray):
                - 'L' for unsigned 64 bit integer
                - 'F' for 32 bit complex number
                - 'D' for 64 bit complex number
-           - if ctypes.c_int, must be one of the following:
-               - f32 for float
-               - f64 for double
-               - b8  for bool
-               - u8  for unsigned char
-               - s32 for signed 32 bit integer
-               - u32 for unsigned 32 bit integer
-               - s64 for signed 64 bit integer
-               - u64 for unsigned 64 bit integer
-               - c32 for 32 bit complex number
-               - c64 for 64 bit complex number
-            - if None, f32 is assumed
+           - if arrayfire.Dtype, must be one of the following:
+               - Dtype.f32 for float
+               - Dtype.f64 for double
+               - Dtype.b8  for bool
+               - Dtype.u8  for unsigned char
+               - Dtype.s32 for signed 32 bit integer
+               - Dtype.u32 for unsigned 32 bit integer
+               - Dtype.s64 for signed 64 bit integer
+               - Dtype.u64 for unsigned 64 bit integer
+               - Dtype.c32 for 32 bit complex number
+               - Dtype.c64 for 64 bit complex number
+            - if None, Dtype.f32 is assumed
 
     Attributes
     -----------
@@ -281,7 +283,6 @@ class Array(BaseArray):
             type_char = None
 
         _type_char='f'
-        dtype = f32
 
         backend.lock()
 
@@ -318,8 +319,6 @@ class Array(BaseArray):
 
                 _type_char = type_char
 
-                print(_type_char)
-
             else:
                 raise TypeError("src is an object of unsupported class")
 
@@ -389,11 +388,11 @@ class Array(BaseArray):
 
     def dtype(self):
         """
-        Return the data type as a ctypes.c_int value.
+        Return the data type as a arrayfire.Dtype enum value.
         """
-        dty = ct.c_int(f32.value)
+        dty = ct.c_int(Dtype.f32.value)
         safe_call(backend.get().af_get_type(ct.pointer(dty), self.arr))
-        return dty
+        return Dtype(dty.value)
 
     def type(self):
         """
diff --git a/arrayfire/blas.py b/arrayfire/blas.py
index 29a8f93..9c1eb3e 100644
--- a/arrayfire/blas.py
+++ b/arrayfire/blas.py
@@ -10,32 +10,32 @@
 from .library import *
 from .array import *
 
-def matmul(lhs, rhs, lhs_opts=AF_MAT_NONE, rhs_opts=AF_MAT_NONE):
+def matmul(lhs, rhs, lhs_opts=MATPROP.NONE, rhs_opts=MATPROP.NONE):
     out = Array()
     safe_call(backend.get().af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,
-                                      lhs_opts, rhs_opts))
+                                      lhs_opts.value, rhs_opts.value))
     return out
 
 def matmulTN(lhs, rhs):
     out = Array()
     safe_call(backend.get().af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,
-                                      AF_MAT_TRANS, AF_MAT_NONE))
+                                      MATPROP.TRANS.value, MATPROP.NONE.value))
     return out
 
 def matmulNT(lhs, rhs):
     out = Array()
     safe_call(backend.get().af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,
-                                      AF_MAT_NONE, AF_MAT_TRANS))
+                                      MATPROP.NONE.value, MATPROP.TRANS.value))
     return out
 
 def matmulTT(lhs, rhs):
     out = Array()
     safe_call(backend.get().af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,
-                                      AF_MAT_TRANS, AF_MAT_TRANS))
+                                      MATPROP.TRANS.value, MATPROP.TRANS.value))
     return out
 
-def dot(lhs, rhs, lhs_opts=AF_MAT_NONE, rhs_opts=AF_MAT_NONE):
+def dot(lhs, rhs, lhs_opts=MATPROP.NONE, rhs_opts=MATPROP.NONE):
     out = Array()
     safe_call(backend.get().af_dot(ct.pointer(out.arr), lhs.arr, rhs.arr,
-                                   lhs_opts, rhs_opts))
+                                   lhs_opts.value, rhs_opts.value))
     return out
diff --git a/arrayfire/data.py b/arrayfire/data.py
index 04c143b..b7db403 100644
--- a/arrayfire/data.py
+++ b/arrayfire/data.py
@@ -12,35 +12,24 @@ from .library import *
 from .array import *
 from .util import *
 
-def constant(val, d0, d1=None, d2=None, d3=None, dtype=f32):
+def constant(val, d0, d1=None, d2=None, d3=None, dtype=Dtype.f32):
     out = Array()
-    out.arr = constant_array(val, d0, d1, d2, d3, dtype)
+    out.arr = constant_array(val, d0, d1, d2, d3, dtype.value)
     return out
 
 # Store builtin range function to be used later
 _brange = range
 
-def range(d0, d1=None, d2=None, d3=None, dim=-1, dtype=f32):
-
-    if not isinstance(dtype, ct.c_int):
-        if isinstance(dtype, int):
-            dtype = ct.c_int(dtype)
-        else:
-            raise TypeError("Invalid dtype")
+def range(d0, d1=None, d2=None, d3=None, dim=-1, dtype=Dtype.f32):
 
     out = Array()
     dims = dim4(d0, d1, d2, d3)
 
-    safe_call(backend.get().af_range(ct.pointer(out.arr), 4, ct.pointer(dims), dim, dtype))
+    safe_call(backend.get().af_range(ct.pointer(out.arr), 4, ct.pointer(dims), dim, dtype.value))
     return out
 
 
-def iota(d0, d1=None, d2=None, d3=None, dim=-1, tile_dims=None, dtype=f32):
-    if not isinstance(dtype, ct.c_int):
-        if isinstance(dtype, int):
-            dtype = ct.c_int(dtype)
-        else:
-            raise TypeError("Invalid dtype")
+def iota(d0, d1=None, d2=None, d3=None, dim=-1, tile_dims=None, dtype=Dtype.f32):
 
     out = Array()
     dims = dim4(d0, d1, d2, d3)
@@ -52,35 +41,24 @@ def iota(d0, d1=None, d2=None, d3=None, dim=-1, tile_dims=None, dtype=f32):
 
     tdims = dim4(td[0], td[1], td[2], td[3])
 
-    safe_call(backend.get().af_iota(ct.pointer(out.arr), 4, ct.pointer(dims), 4, ct.pointer(tdims), dtype))
+    safe_call(backend.get().af_iota(ct.pointer(out.arr), 4, ct.pointer(dims),
+                                    4, ct.pointer(tdims), dtype.value))
     return out
 
-def randu(d0, d1=None, d2=None, d3=None, dtype=f32):
-
-    if not isinstance(dtype, ct.c_int):
-        if isinstance(dtype, int):
-            dtype = ct.c_int(dtype)
-        else:
-            raise TypeError("Invalid dtype")
+def randu(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32):
 
     out = Array()
     dims = dim4(d0, d1, d2, d3)
 
-    safe_call(backend.get().af_randu(ct.pointer(out.arr), 4, ct.pointer(dims), dtype))
+    safe_call(backend.get().af_randu(ct.pointer(out.arr), 4, ct.pointer(dims), dtype.value))
     return out
 
-def randn(d0, d1=None, d2=None, d3=None, dtype=f32):
-
-    if not isinstance(dtype, ct.c_int):
-        if isinstance(dtype, int):
-            dtype = ct.c_int(dtype)
-        else:
-            raise TypeError("Invalid dtype")
+def randn(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32):
 
     out = Array()
     dims = dim4(d0, d1, d2, d3)
 
-    safe_call(backend.get().af_randn(ct.pointer(out.arr), 4, ct.pointer(dims), dtype))
+    safe_call(backend.get().af_randn(ct.pointer(out.arr), 4, ct.pointer(dims), dtype.value))
     return out
 
 def set_seed(seed=0):
@@ -91,18 +69,12 @@ def get_seed():
     safe_call(backend.get().af_get_seed(ct.pointer(seed)))
     return seed.value
 
-def identity(d0, d1=None, d2=None, d3=None, dtype=f32):
-
-    if not isinstance(dtype, ct.c_int):
-        if isinstance(dtype, int):
-            dtype = ct.c_int(dtype)
-        else:
-            raise TypeError("Invalid dtype")
+def identity(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32):
 
     out = Array()
     dims = dim4(d0, d1, d2, d3)
 
-    safe_call(backend.get().af_identity(ct.pointer(out.arr), 4, ct.pointer(dims), dtype))
+    safe_call(backend.get().af_identity(ct.pointer(out.arr), 4, ct.pointer(dims), dtype.value))
     return out
 
 def diag(a, num=0, extract=True):
diff --git a/arrayfire/graphics.py b/arrayfire/graphics.py
index 5b66a14..8e77a28 100644
--- a/arrayfire/graphics.py
+++ b/arrayfire/graphics.py
@@ -28,7 +28,7 @@ class window(object):
         self._r = -1
         self._c = -1
         self._wnd = ct.c_longlong(0)
-        self._cmap = AF_COLORMAP_DEFAULT
+        self._cmap = COLORMAP.DEFAULT
 
         _width  = 1280 if  width is None else  width
         _height =  720 if height is None else height
@@ -37,7 +37,8 @@ class window(object):
         _title = _title.encode("ascii")
 
         safe_call(backend.get().af_create_window(ct.pointer(self._wnd),
-                                                 ct.c_int(_width), ct.c_int(_height), ct.c_char_p(_title)))
+                                                 ct.c_int(_width), ct.c_int(_height),
+                                                 ct.c_char_p(_title)))
 
     def __del__(self):
         safe_call(backend.get().af_destroy_window(self._wnd))
diff --git a/arrayfire/image.py b/arrayfire/image.py
index 6b3415f..9ea283b 100644
--- a/arrayfire/image.py
+++ b/arrayfire/image.py
@@ -30,7 +30,7 @@ def save_image(image, file_name):
     safe_call(backend.get().af_save_image(ct.c_char_p(file_name.encode('ascii')), image.arr))
     return image
 
-def resize(image, scale=None, odim0=None, odim1=None, method=AF_INTERP_NEAREST):
+def resize(image, scale=None, odim0=None, odim1=None, method=INTERP.NEAREST):
 
     if (scale is None):
         assert(odim0 is not None)
@@ -42,40 +42,45 @@ def resize(image, scale=None, odim0=None, odim1=None, method=AF_INTERP_NEAREST):
 
     output = Array()
     safe_call(backend.get().af_resize(ct.pointer(output.arr),
-                                      image.arr, ct.c_longlong(odim0), ct.c_longlong(odim1), method))
+                                      image.arr, ct.c_longlong(odim0),
+                                      ct.c_longlong(odim1), method.value))
 
     return output
 
-def transform(image, transform, odim0 = 0, odim1 = 0, method=AF_INTERP_NEAREST, is_inverse=True):
+def transform(image, transform, odim0 = 0, odim1 = 0, method=INTERP.NEAREST, is_inverse=True):
     output = Array()
     safe_call(backend.get().af_transform(ct.pointer(output.arr),
                                          image.arr, transform.arr,
-                                         ct.c_longlong(odim0), ct.c_longlong(odim1), method, is_inverse))
+                                         ct.c_longlong(odim0), ct.c_longlong(odim1),
+                                         method.value, is_inverse))
     return output
 
-def rotate(image, theta, is_crop = True, method = AF_INTERP_NEAREST):
+def rotate(image, theta, is_crop = True, method = INTERP.NEAREST):
     output = Array()
-    safe_call(backend.get().af_rotate(ct.pointer(output.arr), image.arr, ct.c_double(theta), is_crop, method))
+    safe_call(backend.get().af_rotate(ct.pointer(output.arr), image.arr,
+                                      ct.c_double(theta), is_crop, method.value))
     return output
 
-def translate(image, trans0, trans1, odim0 = 0, odim1 = 0, method = AF_INTERP_NEAREST):
+def translate(image, trans0, trans1, odim0 = 0, odim1 = 0, method = INTERP.NEAREST):
     output = Array()
     safe_call(backend.get().af_translate(ct.pointer(output.arr),
-                                         image.arr, trans0, trans1, ct.c_longlong(odim0), ct.c_longlong(odim1), method))
+                                         image.arr, trans0, trans1,
+                                         ct.c_longlong(odim0), ct.c_longlong(odim1), method.value))
     return output
 
-def scale(image, scale0, scale1, odim0 = 0, odim1 = 0, method = AF_INTERP_NEAREST):
+def scale(image, scale0, scale1, odim0 = 0, odim1 = 0, method = INTERP.NEAREST):
     output = Array()
     safe_call(backend.get().af_scale(ct.pointer(output.arr),
                                      image.arr, ct.c_double(scale0), ct.c_double(scale1),
-                                     ct.c_longlong(odim0), ct.c_longlong(odim1), method))
+                                     ct.c_longlong(odim0), ct.c_longlong(odim1), method.value))
     return output
 
-def skew(image, skew0, skew1, odim0 = 0, odim1 = 0, method = AF_INTERP_NEAREST, is_inverse=True):
+def skew(image, skew0, skew1, odim0 = 0, odim1 = 0, method = INTERP.NEAREST, is_inverse=True):
     output = Array()
     safe_call(backend.get().af_skew(ct.pointer(output.arr),
                                     image.arr, ct.c_double(skew0), ct.c_double(skew1),
-                                    ct.c_longlong(odim0), ct.c_longlong(odim1), method, is_inverse))
+                                    ct.c_longlong(odim0), ct.c_longlong(odim1),
+                                    method.value, is_inverse))
 
     return output
 
@@ -91,7 +96,8 @@ def histogram(image, nbins, min_val = None, max_val = None):
 
     output = Array()
     safe_call(backend.get().af_histogram(ct.pointer(output.arr),
-                                         image.arr, ct.c_uint(nbins), ct.c_double(min_val), ct.c_double(max_val)))
+                                         image.arr, ct.c_uint(nbins),
+                                         ct.c_double(min_val), ct.c_double(max_val)))
     return output
 
 def hist_equal(image, hist):
@@ -102,7 +108,7 @@ def hist_equal(image, hist):
 def dilate(image, mask = None):
 
     if mask is None:
-        mask = constant(1, 3, 3, dtype=f32)
+        mask = constant(1, 3, 3, dtype=Dtype.f32)
 
     output = Array()
     safe_call(backend.get().af_dilate(ct.pointer(output.arr), image.arr, mask.arr))
@@ -112,7 +118,7 @@ def dilate(image, mask = None):
 def dilate3(image, mask = None):
 
     if mask is None:
-        mask = constant(1, 3, 3, 3, dtype=f32)
+        mask = constant(1, 3, 3, 3, dtype=Dtype.f32)
 
     output = Array()
     safe_call(backend.get().af_dilate3(ct.pointer(output.arr), image.arr, mask.arr))
@@ -122,7 +128,7 @@ def dilate3(image, mask = None):
 def erode(image, mask = None):
 
     if mask is None:
-        mask = constant(1, 3, 3, dtype=f32)
+        mask = constant(1, 3, 3, dtype=Dtype.f32)
 
     output = Array()
     safe_call(backend.get().af_erode(ct.pointer(output.arr), image.arr, mask.arr))
@@ -132,7 +138,7 @@ def erode(image, mask = None):
 def erode3(image, mask = None):
 
     if mask is None:
-        mask = constant(1, 3, 3, 3, dtype=f32)
+        mask = constant(1, 3, 3, 3, dtype=Dtype.f32)
 
     output = Array()
     safe_call(backend.get().af_erode3(ct.pointer(output.arr), image.arr, mask.arr))
@@ -142,7 +148,8 @@ def erode3(image, mask = None):
 def bilateral(image, s_sigma, c_sigma, is_color = False):
     output = Array()
     safe_call(backend.get().af_bilateral(ct.pointer(output.arr),
-                                         image.arr, ct.c_double(s_sigma), ct.c_double(c_sigma), is_color))
+                                         image.arr, ct.c_double(s_sigma),
+                                         ct.c_double(c_sigma), is_color))
     return output
 
 def mean_shift(image, s_sigma, c_sigma, n_iter, is_color = False):
@@ -152,27 +159,31 @@ def mean_shift(image, s_sigma, c_sigma, n_iter, is_color = False):
                                           ct.c_uint(n_iter), is_color))
     return output
 
-def medfilt(image, w_len = 3, w_wid = 3, edge_pad = AF_PAD_ZERO):
+def medfilt(image, w_len = 3, w_wid = 3, edge_pad = PAD.ZERO):
     output = Array()
     safe_call(backend.get().af_medfilt(ct.pointer(output.arr),
-                                       image.arr, ct.c_longlong(w_len), ct.c_longlong(w_wid), edge_pad))
+                                       image.arr, ct.c_longlong(w_len),
+                                       ct.c_longlong(w_wid), edge_pad.value))
     return output
 
-def minfilt(image, w_len = 3, w_wid = 3, edge_pad = AF_PAD_ZERO):
+def minfilt(image, w_len = 3, w_wid = 3, edge_pad = PAD.ZERO):
     output = Array()
     safe_call(backend.get().af_minfilt(ct.pointer(output.arr),
-                                       image.arr, ct.c_longlong(w_len), ct.c_longlong(w_wid), edge_pad))
+                                       image.arr, ct.c_longlong(w_len),
+                                       ct.c_longlong(w_wid), edge_pad.value))
     return output
 
-def maxfilt(image, w_len = 3, w_wid = 3, edge_pad = AF_PAD_ZERO):
+def maxfilt(image, w_len = 3, w_wid = 3, edge_pad = PAD.ZERO):
     output = Array()
     safe_call(backend.get().af_maxfilt(ct.pointer(output.arr),
-                                       image.arr, ct.c_longlong(w_len), ct.c_longlong(w_wid), edge_pad))
+                                       image.arr, ct.c_longlong(w_len),
+                                       ct.c_longlong(w_wid), edge_pad.value))
     return output
 
-def regions(image, connectivity = AF_CONNECTIVITY_4, out_type = f32):
+def regions(image, connectivity = CONNECTIVITY.FOUR, out_type = Dtype.f32):
     output = Array()
-    safe_call(backend.get().af_regions(ct.pointer(output.arr), image.arr, connectivity, out_type))
+    safe_call(backend.get().af_regions(ct.pointer(output.arr), image.arr,
+                                       connectivity.value, out_type.value))
     return output
 
 def sobel_derivatives(image, w_len=3):
@@ -216,5 +227,6 @@ def rgb2hsv(image):
 
 def color_space(image, to_type, from_type):
     output = Array()
-    safe_call(backend.get().af_color_space(ct.pointer(output.arr), image.arr, to_type, from_type))
+    safe_call(backend.get().af_color_space(ct.pointer(output.arr), image.arr,
+                                           to_type.value, from_type.value))
     return output
diff --git a/arrayfire/lapack.py b/arrayfire/lapack.py
index f324daf..f1fcebf 100644
--- a/arrayfire/lapack.py
+++ b/arrayfire/lapack.py
@@ -46,19 +46,19 @@ def cholesky_inplace(A, is_upper=True):
     safe_call(backend.get().af_cholesky_inplace(ct.pointer(info), A.arr, is_upper))
     return info.value
 
-def solve(A, B, options=AF_MAT_NONE):
+def solve(A, B, options=MATPROP.NONE):
     X = Array()
-    safe_call(backend.get().af_solve(ct.pointer(X.arr), A.arr, B.arr, options))
+    safe_call(backend.get().af_solve(ct.pointer(X.arr), A.arr, B.arr, options.value))
     return X
 
-def solve_lu(A, P, B, options=AF_MAT_NONE):
+def solve_lu(A, P, B, options=MATPROP.NONE):
     X = Array()
-    safe_call(backend.get().af_solve_lu(ct.pointer(X.arr), A.arr, P.arr, B.arr, options))
+    safe_call(backend.get().af_solve_lu(ct.pointer(X.arr), A.arr, P.arr, B.arr, options.value))
     return X
 
-def inverse(A, options=AF_MAT_NONE):
+def inverse(A, options=MATPROP.NONE):
     I = Array()
-    safe_call(backend.get().af_inverse(ct.pointer(I.arr), A.arr, options))
+    safe_call(backend.get().af_inverse(ct.pointer(I.arr), A.arr, options.value))
     return I
 
 def rank(A, tol=1E-5):
@@ -74,7 +74,8 @@ def det(A):
     im = im.value
     return re if (im == 0) else re + im * 1j
 
-def norm(A, norm_type=AF_NORM_EUCLID, p=1.0, q=1.0):
+def norm(A, norm_type=NORM.EUCLID, p=1.0, q=1.0):
     res = ct.c_double(0)
-    safe_call(backend.get().af_norm(ct.pointer(res), A.arr, norm_type, ct.c_double(p), ct.c_double(q)))
+    safe_call(backend.get().af_norm(ct.pointer(res), A.arr, norm_type.value,
+                                    ct.c_double(p), ct.c_double(q)))
     return res.value
diff --git a/arrayfire/library.py b/arrayfire/library.py
index 9aff623..a060276 100644
--- a/arrayfire/library.py
+++ b/arrayfire/library.py
@@ -9,6 +9,7 @@
 
 import platform
 import ctypes as ct
+from enum import Enum
 
 class _clibrary(object):
 
@@ -70,105 +71,121 @@ class _clibrary(object):
 backend = _clibrary()
 del _clibrary
 
-AF_SUCCESS            =   ct.c_int(0)
-
-#100-199 Errors in environment
-AF_ERR_NO_MEM         = ct.c_int(101)
-AF_ERR_DRIVER         = ct.c_int(102)
-AF_ERR_RUNTIME        = ct.c_int(103)
-
-# 200-299 Errors in input parameters
-AF_ERR_INVALID_ARRAY  = ct.c_int(201)
-AF_ERR_ARG            = ct.c_int(202)
-AF_ERR_SIZE           = ct.c_int(203)
-AF_ERR_TYPE           = ct.c_int(204)
-AF_ERR_DIFF_TYPE      = ct.c_int(205)
-AF_ERR_BATCH          = ct.c_int(207)
-
-# 300-399 Errors for missing software features
-AF_ERR_NOT_SUPPORTED  = ct.c_int(301)
-AF_ERR_NOT_CONFIGURED = ct.c_int(302)
-
-# 400-499 Errors for missing hardware features
-AF_ERR_NO_DBL         = ct.c_int(401)
-AF_ERR_NO_GFX         = ct.c_int(402)
-
-# 900-999 Errors from upstream libraries and runtimes
-AF_ERR_INTERNAL       = ct.c_int(998)
-AF_ERR_UNKNOWN        = ct.c_int(999)
-
-f32 = ct.c_int(0)
-c32 = ct.c_int(1)
-f64 = ct.c_int(2)
-c64 = ct.c_int(3)
-b8  = ct.c_int(4)
-s32 = ct.c_int(5)
-u32 = ct.c_int(6)
-u8  = ct.c_int(7)
-s64 = ct.c_int(8)
-u64 = ct.c_int(9)
-
-afDevice = ct.c_int(0)
-afHost   = ct.c_int(1)
-
-AF_INTERP_NEAREST   = ct.c_int(0)
-AF_INTERP_LINEAR    = ct.c_int(1)
-AF_INTERP_BILINEAR  = ct.c_int(2)
-AF_INTERP_CUBIC     = ct.c_int(3)
-
-AF_PAD_ZERO = ct.c_int(0)
-AF_PAD_SYM  = ct.c_int(1)
-
-AF_CONNECTIVITY_4 = ct.c_int(4)
-AF_CONNECTIVITY_8 = ct.c_int(8)
-
-AF_CONV_DEFAULT = ct.c_int(0)
-AF_CONV_EXPAND  = ct.c_int(1)
-
-AF_CONV_AUTO    = ct.c_int(0)
-AF_CONV_SPATIAL = ct.c_int(1)
-AF_CONV_FREQ    = ct.c_int(2)
-
-AF_SAD  = ct.c_int(0)
-AF_ZSAD = ct.c_int(1)
-AF_LSAD = ct.c_int(2)
-AF_SSD  = ct.c_int(3)
-AF_ZSSD = ct.c_int(4)
-AF_LSSD = ct.c_int(5)
-AF_NCC  = ct.c_int(6)
-AF_ZNCC = ct.c_int(7)
-AF_SHD  = ct.c_int(8)
-
-AF_GRAY = ct.c_int(0)
-AF_RGB  = ct.c_int(1)
-AF_HSV  = ct.c_int(2)
-
-AF_MAT_NONE       = ct.c_int(0)
-AF_MAT_TRANS      = ct.c_int(1)
-AF_MAT_CTRANS     = ct.c_int(2)
-AF_MAT_UPPER      = ct.c_int(32)
-AF_MAT_LOWER      = ct.c_int(64)
-AF_MAT_DIAG_UNIT  = ct.c_int(128)
-AF_MAT_SYM        = ct.c_int(512)
-AF_MAT_POSDEF     = ct.c_int(1024)
-AF_MAT_ORTHOG     = ct.c_int(2048)
-AF_MAT_TRI_DIAG   = ct.c_int(4096)
-AF_MAT_BLOCK_DIAG = ct.c_int(8192)
-
-AF_NORM_VECTOR_1    = ct.c_int(0)
-AF_NORM_VECTOR_INF  = ct.c_int(1)
-AF_NORM_VECTOR_2    = ct.c_int(2)
-AF_NORM_VECTOR_P    = ct.c_int(3)
-AF_NORM_MATRIX_1    = ct.c_int(4)
-AF_NORM_MATRIX_INF  = ct.c_int(5)
-AF_NORM_MATRIX_2    = ct.c_int(6)
-AF_NORM_MATRIX_L_PQ = ct.c_int(7)
-AF_NORM_EUCLID      = AF_NORM_VECTOR_2
-
-AF_COLORMAP_DEFAULT  = ct.c_int(0)
-AF_COLORMAP_SPECTRUM = ct.c_int(1)
-AF_COLORMAP_COLORS   = ct.c_int(2)
-AF_COLORMAP_RED      = ct.c_int(3)
-AF_COLORMAP_MOOD     = ct.c_int(4)
-AF_COLORMAP_HEAT     = ct.c_int(5)
-AF_COLORMAP_BLUE     = ct.c_int(6)
+
+class ERR(Enum):
+    NONE            =   (0)
+
+    #100-199 Errors in environment
+    NO_MEM         = (101)
+    DRIVER         = (102)
+    RUNTIME        = (103)
+
+    # 200-299 Errors in input parameters
+    INVALID_ARRAY  = (201)
+    ARG            = (202)
+    SIZE           = (203)
+    TYPE           = (204)
+    DIFF_TYPE      = (205)
+    BATCH          = (207)
+
+    # 300-399 Errors for missing software features
+    NOT_SUPPORTED  = (301)
+    NOT_CONFIGURED = (302)
+
+    # 400-499 Errors for missing hardware features
+    NO_DBL         = (401)
+    NO_GFX         = (402)
+
+    # 900-999 Errors from upstream libraries and runtimes
+    INTERNAL       = (998)
+    UNKNOWN        = (999)
+
+class Dtype(Enum):
+    f32 = (0)
+    c32 = (1)
+    f64 = (2)
+    c64 = (3)
+    b8  = (4)
+    s32 = (5)
+    u32 = (6)
+    u8  = (7)
+    s64 = (8)
+    u64 = (9)
+
+class Source(Enum):
+    device = (0)
+    host   = (1)
+
+class INTERP(Enum):
+    NEAREST   = (0)
+    LINEAR    = (1)
+    BILINEAR  = (2)
+    CUBIC     = (3)
+
+class PAD(Enum):
+    ZERO = (0)
+    SYM  = (1)
+
+class CONNECTIVITY(Enum):
+    FOUR  = (4)
+    EIGHT = (8)
+
+class CONV_MODE(Enum):
+    DEFAULT = (0)
+    EXPAND  = (1)
+
+class CONV_DOMAIN(Enum):
+    AUTO    = (0)
+    SPATIAL = (1)
+    FREQ    = (2)
+
+class MATCH(Enum):
+    SAD  = (0)
+    ZSAD = (1)
+    LSAD = (2)
+    SSD  = (3)
+    ZSSD = (4)
+    LSSD = (5)
+    NCC  = (6)
+    ZNCC = (7)
+    SHD  = (8)
+
+class CSPACE(Enum):
+    GRAY = (0)
+    RGB  = (1)
+    HSV  = (2)
+
+class MATPROP(Enum):
+    NONE       = (0)
+    TRANS      = (1)
+    CTRANS     = (2)
+    UPPER      = (32)
+    LOWER      = (64)
+    DIAG_UNIT  = (128)
+    SYM        = (512)
+    POSDEF     = (1024)
+    ORTHOG     = (2048)
+    TRI_DIAG   = (4096)
+    BLOCK_DIAG = (8192)
+
+class NORM(Enum):
+    VECTOR_1    = (0)
+    VECTOR_INF  = (1)
+    VECTOR_2    = (2)
+    VECTOR_P    = (3)
+    MATRIX_1    = (4)
+    MATRIX_INF  = (5)
+    MATRIX_2    = (6)
+    MATRIX_L_PQ = (7)
+    EUCLID      = VECTOR_2
+
+class COLORMAP(Enum):
+    DEFAULT  = (0)
+    SPECTRUM = (1)
+    COLORS   = (2)
+    RED      = (3)
+    MOOD     = (4)
+    HEAT     = (5)
+    BLUE     = (6)
+
+del Enum
diff --git a/arrayfire/signal.py b/arrayfire/signal.py
index a37854d..10793fe 100644
--- a/arrayfire/signal.py
+++ b/arrayfire/signal.py
@@ -10,16 +10,16 @@
 from .library import *
 from .array import *
 
-def approx1(signal, pos0, method=AF_INTERP_LINEAR, off_grid=0.0):
+def approx1(signal, pos0, method=INTERP.LINEAR, off_grid=0.0):
     output = Array()
     safe_call(backend.get().af_approx1(ct.pointer(output.arr), signal.arr, pos0.arr,
-                                       method, ct.c_double(off_grid)))
+                                       method.value, ct.c_double(off_grid)))
     return output
 
-def approx2(signal, pos0, pos1, method=AF_INTERP_LINEAR, off_grid=0.0):
+def approx2(signal, pos0, pos1, method=INTERP.LINEAR, off_grid=0.0):
     output = Array()
     safe_call(backend.get().af_approx2(ct.pointer(output.arr), signal.arr,
-                                       pos0.arr, pos1.arr, method, ct.c_double(off_grid)))
+                                       pos0.arr, pos1.arr, method.value, ct.c_double(off_grid)))
     return output
 
 def fft(signal, dim0 = None , scale = None):
@@ -154,22 +154,25 @@ def idft(signal, scale = None, odims=(None, None, None, None)):
     else:
         return ifft3(signal, scale, dims[0], dims[1], dims[2])
 
-def convolve1(signal, kernel, conv_mode = AF_CONV_DEFAULT, conv_domain = AF_CONV_AUTO):
+def convolve1(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_DOMAIN.AUTO):
     output = Array()
-    safe_call(backend.get().af_convolve1(ct.pointer(output.arr), signal.arr, kernel.arr, conv_mode, conv_domain))
+    safe_call(backend.get().af_convolve1(ct.pointer(output.arr), signal.arr, kernel.arr,
+                                         conv_mode.value, conv_domain.value))
     return output
 
-def convolve2(signal, kernel, conv_mode = AF_CONV_DEFAULT, conv_domain = AF_CONV_AUTO):
+def convolve2(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_DOMAIN.AUTO):
     output = Array()
-    safe_call(backend.get().af_convolve2(ct.pointer(output.arr), signal.arr, kernel.arr, conv_mode, conv_domain))
+    safe_call(backend.get().af_convolve2(ct.pointer(output.arr), signal.arr, kernel.arr,
+                                         conv_mode.value, conv_domain.value))
     return output
 
-def convolve3(signal, kernel, conv_mode = AF_CONV_DEFAULT, conv_domain = AF_CONV_AUTO):
+def convolve3(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_DOMAIN.AUTO):
     output = Array()
-    safe_call(backend.get().af_convolve3(ct.pointer(output.arr), signal.arr, kernel.arr, conv_mode, conv_domain))
+    safe_call(backend.get().af_convolve3(ct.pointer(output.arr), signal.arr, kernel.arr,
+                                         conv_mode.value, conv_domain.value))
     return output
 
-def convolve(signal, kernel, conv_mode = AF_CONV_DEFAULT, conv_domain = AF_CONV_AUTO):
+def convolve(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_DOMAIN.AUTO):
     dims = signal.dims()
     ndims = len(dims)
 
@@ -180,22 +183,25 @@ def convolve(signal, kernel, conv_mode = AF_CONV_DEFAULT, conv_domain = AF_CONV_
     else:
         return convolve3(signal, kernel, conv_mode, conv_domain)
 
-def fft_convolve1(signal, kernel, conv_mode = AF_CONV_DEFAULT):
+def fft_convolve1(signal, kernel, conv_mode = CONV_MODE.DEFAULT):
     output = Array()
-    safe_call(backend.get().af_fft_convolve1(ct.pointer(output.arr), signal.arr, kernel.arr, conv_mode))
+    safe_call(backend.get().af_fft_convolve1(ct.pointer(output.arr), signal.arr, kernel.arr,
+                                             conv_mode.value))
     return output
 
-def fft_convolve2(signal, kernel, conv_mode = AF_CONV_DEFAULT):
+def fft_convolve2(signal, kernel, conv_mode = CONV_MODE.DEFAULT):
     output = Array()
-    safe_call(backend.get().af_fft_convolve2(ct.pointer(output.arr), signal.arr, kernel.arr, conv_mode))
+    safe_call(backend.get().af_fft_convolve2(ct.pointer(output.arr), signal.arr, kernel.arr,
+                                             conv_mode.value))
     return output
 
-def fft_convolve3(signal, kernel, conv_mode = AF_CONV_DEFAULT):
+def fft_convolve3(signal, kernel, conv_mode = CONV_MODE.DEFAULT):
     output = Array()
-    safe_call(backend.get().af_fft_convolve3(ct.pointer(output.arr), signal.arr, kernel.arr, conv_mode))
+    safe_call(backend.get().af_fft_convolve3(ct.pointer(output.arr), signal.arr, kernel.arr,
+                                             conv_mode.value))
     return output
 
-def fft_convolve(signal, kernel, conv_mode = AF_CONV_DEFAULT):
+def fft_convolve(signal, kernel, conv_mode = CONV_MODE.DEFAULT):
     dims = signal.dims()
     ndims = len(dims)
 
diff --git a/arrayfire/util.py b/arrayfire/util.py
index d6ad2df..e7ae775 100644
--- a/arrayfire/util.py
+++ b/arrayfire/util.py
@@ -24,13 +24,13 @@ def is_number(a):
 
 def number_dtype(a):
     if isinstance(a, bool):
-        return b8
+        return Dtype.b8
     if isinstance(a, int):
-        return s64
+        return Dtype.s64
     elif isinstance(a, float):
-        return f64
+        return Dtype.f64
     elif isinstance(a, complex):
-        return c64
+        return Dtype.c64
     else:
         return to_dtype[a.dtype.char]
 
@@ -38,16 +38,16 @@ def implicit_dtype(number, a_dtype):
     n_dtype = number_dtype(number)
     n_value = n_dtype.value
 
-    f64v = f64.value
-    f32v = f32.value
-    c32v = c32.value
-    c64v = c64.value
+    f64v = Dtype.f64.value
+    f32v = Dtype.f32.value
+    c32v = Dtype.c32.value
+    c64v = Dtype.c64.value
 
     if n_value == f64v and (a_dtype == f32v or a_dtype == c32v):
-        return f32
+        return Dtype.f32
 
     if n_value == c64v and (a_dtype == f32v or a_dtype == c32v):
-        return c32
+        return Dtype.c32
 
     return n_dtype
 
@@ -68,7 +68,7 @@ def to_str(c_str):
     return str(c_str.value.decode('utf-8'))
 
 def safe_call(af_error):
-    if (af_error != AF_SUCCESS.value):
+    if (af_error != ERR.NONE.value):
         err_str = ct.c_char_p(0)
         err_len = ct.c_longlong(0)
         backend.get().af_get_last_error(ct.pointer(err_str), ct.pointer(err_len))
@@ -81,35 +81,35 @@ def get_version():
     safe_call(backend.get().af_get_version(ct.pointer(major), ct.pointer(minor), ct.pointer(patch)))
     return major,minor,patch
 
-to_dtype = {'f' : f32,
-            'd' : f64,
-            'b' : b8,
-            'B' : u8,
-            'i' : s32,
-            'I' : u32,
-            'l' : s64,
-            'L' : u64,
-            'F' : c32,
-            'D' : c64}
-
-to_typecode = {f32.value : 'f',
-               f64.value : 'd',
-               b8.value : 'b',
-               u8.value : 'B',
-               s32.value : 'i',
-               u32.value : 'I',
-               s64.value : 'l',
-               u64.value : 'L',
-               c32.value : 'F',
-               c64.value : 'D'}
-
-to_c_type = {f32.value : ct.c_float,
-             f64.value : ct.c_double,
-             b8.value : ct.c_char,
-             u8.value : ct.c_ubyte,
-             s32.value : ct.c_int,
-             u32.value : ct.c_uint,
-             s64.value : ct.c_longlong,
-             u64.value : ct.c_ulonglong,
-             c32.value : ct.c_float * 2,
-             c64.value : ct.c_double * 2}
+to_dtype = {'f' : Dtype.f32,
+            'd' : Dtype.f64,
+            'b' : Dtype.b8,
+            'B' : Dtype.u8,
+            'i' : Dtype.s32,
+            'I' : Dtype.u32,
+            'l' : Dtype.s64,
+            'L' : Dtype.u64,
+            'F' : Dtype.c32,
+            'D' : Dtype.c64}
+
+to_typecode = {Dtype.f32.value : 'f',
+               Dtype.f64.value : 'd',
+               Dtype.b8.value : 'b',
+               Dtype.u8.value : 'B',
+               Dtype.s32.value : 'i',
+               Dtype.u32.value : 'I',
+               Dtype.s64.value : 'l',
+               Dtype.u64.value : 'L',
+               Dtype.c32.value : 'F',
+               Dtype.c64.value : 'D'}
+
+to_c_type = {Dtype.f32.value : ct.c_float,
+             Dtype.f64.value : ct.c_double,
+             Dtype.b8.value : ct.c_char,
+             Dtype.u8.value : ct.c_ubyte,
+             Dtype.s32.value : ct.c_int,
+             Dtype.u32.value : ct.c_uint,
+             Dtype.s64.value : ct.c_longlong,
+             Dtype.u64.value : ct.c_ulonglong,
+             Dtype.c32.value : ct.c_float * 2,
+             Dtype.c64.value : ct.c_double * 2}
diff --git a/arrayfire/vision.py b/arrayfire/vision.py
index 0c0248b..7b43290 100644
--- a/arrayfire/vision.py
+++ b/arrayfire/vision.py
@@ -33,7 +33,7 @@ def hamming_matcher(query, database, dim = 0, num_nearest = 1):
                                                ct.c_longlong(dim), ct.c_longlong(num_nearest)))
     return index, dist
 
-def match_template(image, template, match_type = AF_SAD):
+def match_template(image, template, match_type = MATCH.SAD):
     out = Array()
     safe_call(backend.get().af_match_template(ct.pointer(out.arr), image.arr, template.arr, match_type))
     return out
diff --git a/tests/simple_arith.py b/tests/simple_arith.py
index 30b3596..c2ea3d1 100755
--- a/tests/simple_arith.py
+++ b/tests/simple_arith.py
@@ -10,8 +10,8 @@
 
 import arrayfire as af
 
-a = af.randu(3,3,dtype=af.u32)
-b = af.constant(4, 3, 3, dtype=af.u32)
+a = af.randu(3,3,dtype=af.Dtype.u32)
+b = af.constant(4, 3, 3, dtype=af.Dtype.u32)
 af.display(a)
 af.display(b)
 
@@ -123,7 +123,7 @@ af.display(+a)
 af.display(~a)
 af.display(a)
 
-af.display(af.cast(a, af.c32))
+af.display(af.cast(a, af.Dtype.c32))
 af.display(af.maxof(a,b))
 af.display(af.minof(a,b))
 af.display(af.rem(a,b))
diff --git a/tests/simple_blas.py b/tests/simple_blas.py
index 1fc4afa..47cc4b6 100755
--- a/tests/simple_blas.py
+++ b/tests/simple_blas.py
@@ -14,8 +14,8 @@ a = af.randu(5,5)
 b = af.randu(5,5)
 
 af.display(af.matmul(a,b))
-af.display(af.matmul(a,b,af.AF_MAT_TRANS))
-af.display(af.matmul(a,b,af.AF_MAT_NONE, af.AF_MAT_TRANS))
+af.display(af.matmul(a,b,af.MATPROP.TRANS))
+af.display(af.matmul(a,b,af.MATPROP.NONE, af.MATPROP.TRANS))
 
 b = af.randu(5,1)
 af.display(af.dot(b,b))
diff --git a/tests/simple_data.py b/tests/simple_data.py
index 9bc407f..8945a6b 100755
--- a/tests/simple_data.py
+++ b/tests/simple_data.py
@@ -10,27 +10,27 @@
 
 import arrayfire as af
 
-af.display(af.constant(100, 3,3, dtype=af.f32))
-af.display(af.constant(25, 3,3, dtype=af.c32))
-af.display(af.constant(2**50, 3,3, dtype=af.s64))
+af.display(af.constant(100, 3,3, dtype=af.Dtype.f32))
+af.display(af.constant(25, 3,3, dtype=af.Dtype.c32))
+af.display(af.constant(2**50, 3,3, dtype=af.Dtype.s64))
 af.display(af.constant(2+3j, 3,3))
-af.display(af.constant(3+5j, 3,3, dtype=af.c32))
+af.display(af.constant(3+5j, 3,3, dtype=af.Dtype.c32))
 
 af.display(af.range(3, 3))
 af.display(af.iota(3, 3, tile_dims=(2,2)))
 
 af.display(af.randu(3, 3, 1, 2))
-af.display(af.randu(3, 3, 1, 2, af.b8))
-af.display(af.randu(3, 3, dtype=af.c32))
+af.display(af.randu(3, 3, 1, 2, af.Dtype.b8))
+af.display(af.randu(3, 3, dtype=af.Dtype.c32))
 
 af.display(af.randn(3, 3, 1, 2))
-af.display(af.randn(3, 3, dtype=af.c32))
+af.display(af.randn(3, 3, dtype=af.Dtype.c32))
 
 af.set_seed(1024)
 assert(af.get_seed() == 1024)
 
-af.display(af.identity(3, 3, 1, 2, af.b8))
-af.display(af.identity(3, 3, dtype=af.c32))
+af.display(af.identity(3, 3, 1, 2, af.Dtype.b8))
+af.display(af.identity(3, 3, dtype=af.Dtype.c32))
 
 a = af.randu(3, 4)
 b = af.diag(a, extract=True)
diff --git a/tests/simple_image.py b/tests/simple_image.py
index b6bc01a..cfbbc73 100755
--- a/tests/simple_image.py
+++ b/tests/simple_image.py
@@ -57,4 +57,4 @@ ah = af.rgb2hsv(ac)
 af.display(ah)
 af.display(af.hsv2rgb(ah))
 
-af.display(af.color_space(a, af.AF_RGB, af.AF_GRAY))
+af.display(af.color_space(a, af.CSPACE.RGB, af.CSPACE.GRAY))
diff --git a/tests/simple_index.py b/tests/simple_index.py
index a3c924c..bb87cf3 100755
--- a/tests/simple_index.py
+++ b/tests/simple_index.py
@@ -60,7 +60,7 @@ for ii in ParallelRange(2,5):
 af.display(b)
 
 a = af.randu(3,2)
-rows = af.constant(0, 1, dtype=af.s32)
+rows = af.constant(0, 1, dtype=af.Dtype.s32)
 b = a[:,rows]
 af.display(b)
 for r in rows:
diff --git a/tests/simple_lapack.py b/tests/simple_lapack.py
index 015144b..b7dae1a 100755
--- a/tests/simple_lapack.py
+++ b/tests/simple_lapack.py
@@ -65,7 +65,7 @@ af.display(x2)
 
 print(af.rank(a))
 print(af.det(a))
-print(af.norm(a, af.AF_NORM_EUCLID))
-print(af.norm(a, af.AF_NORM_MATRIX_1))
-print(af.norm(a, af.AF_NORM_MATRIX_INF))
-print(af.norm(a, af.AF_NORM_MATRIX_L_PQ, 1, 1))
+print(af.norm(a, af.NORM.EUCLID))
+print(af.norm(a, af.NORM.MATRIX_1))
+print(af.norm(a, af.NORM.MATRIX_INF))
+print(af.norm(a, af.NORM.MATRIX_L_PQ, 1, 1))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-arrayfire.git



More information about the debian-science-commits mailing list