[python-arrayfire] 109/250: Work around for missing Enum class
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:37 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 ce1ae092310347f2ad28fb3585b80c8e4aa5f501
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date: Tue Sep 8 13:05:28 2015 -0400
Work around for missing Enum class
---
arrayfire/arith.py | 2 +-
arrayfire/array.py | 27 +++++++++++++------------
arrayfire/blas.py | 10 +++++-----
arrayfire/data.py | 12 +++++------
arrayfire/graphics.py | 2 +-
arrayfire/image.py | 22 ++++++++++-----------
arrayfire/lapack.py | 8 ++++----
arrayfire/library.py | 14 ++++++++++++-
arrayfire/signal.py | 16 +++++++--------
arrayfire/util.py | 55 ++++++++++++++++++++++++++-------------------------
10 files changed, 91 insertions(+), 77 deletions(-)
diff --git a/arrayfire/arith.py b/arrayfire/arith.py
index 1aacc91..bec7192 100644
--- a/arrayfire/arith.py
+++ b/arrayfire/arith.py
@@ -74,7 +74,7 @@ def cast(a, dtype):
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.value))
+ safe_call(backend.get().af_cast(ct.pointer(out.arr), a.arr, Enum_value(dtype)))
return out
def minof(lhs, rhs):
diff --git a/arrayfire/array.py b/arrayfire/array.py
index 14f4880..7a41cec 100644
--- a/arrayfire/array.py
+++ b/arrayfire/array.py
@@ -22,14 +22,14 @@ 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.value))
+ numdims, ct.pointer(c_dims), Enum_value(dtype)))
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.value))
+ numdims, ct.pointer(c_dims), Enum_value(dtype)))
return out_arr
def constant_array(val, d0, d1=None, d2=None, d3=None, dtype=Dtype.f32):
@@ -41,7 +41,7 @@ def constant_array(val, d0, d1=None, d2=None, d3=None, dtype=Dtype.f32):
if isinstance(dtype, int):
dtype = ct.c_int(dtype)
elif isinstance(dtype, Dtype):
- dtype = ct.c_int(dtype.value)
+ dtype = ct.c_int(Enum_value(dtype))
else:
raise TypeError("Invalid dtype")
@@ -52,15 +52,16 @@ def constant_array(val, d0, d1=None, d2=None, d3=None, dtype=Dtype.f32):
c_real = ct.c_double(val.real)
c_imag = ct.c_double(val.imag)
- if (dtype.value != Dtype.c32.value and dtype.value != Dtype.c64.value):
- dtype = Dtype.c32.value
+ if (Enum_value(dtype) != Enum_value(Dtype) and Enum_value(dtype) != Enum_value(Dtype)):
+ dtype = Enum_value(Dtype.c32)
safe_call(backend.get().af_constant_complex(ct.pointer(out), c_real, c_imag,
4, ct.pointer(dims), dtype))
- elif dtype.value == Dtype.s64.value:
+
+ elif Enum_value(dtype) == Enum_value(Dtype.s64):
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.value == Dtype.u64.value:
+ elif Enum_value(dtype) == Enum_value(Dtype.u64):
c_val = ct.c_ulonglong(val.real)
safe_call(backend.get().af_constant_ulong(ct.pointer(out), c_val, 4, ct.pointer(dims)))
else:
@@ -78,7 +79,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.value)
+ other.arr = constant_array(rhs, ldims[0], ldims[1], ldims[2], ldims[3], Enum_value(rty))
elif not isinstance(rhs, Array):
raise TypeError("Invalid parameter to binary function")
@@ -94,7 +95,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.value)
+ other.arr = constant_array(lhs, rdims[0], rdims[1], rdims[2], rdims[3], Enum_value(lty))
elif not isinstance(lhs, Array):
raise TypeError("Invalid parameter to binary function")
@@ -350,7 +351,7 @@ class Array(BaseArray):
if isinstance(dtype, str):
type_char = dtype
else:
- type_char = to_typecode[dtype.value]
+ type_char = to_typecode[Enum_value(dtype)]
else:
type_char = None
@@ -462,15 +463,15 @@ class Array(BaseArray):
"""
Return the data type as a arrayfire.Dtype enum value.
"""
- dty = ct.c_int(Dtype.f32.value)
+ dty = ct.c_int(Enum_value(Dtype.f32))
safe_call(backend.get().af_get_type(ct.pointer(dty), self.arr))
- return Dtype(dty.value)
+ return to_dtype[typecodes[dty.value]]
def type(self):
"""
Return the data type as an int.
"""
- return self.dtype().value
+ return Enum_value(self.dtype())
def dims(self):
"""
diff --git a/arrayfire/blas.py b/arrayfire/blas.py
index c476c1c..4de5af9 100644
--- a/arrayfire/blas.py
+++ b/arrayfire/blas.py
@@ -54,7 +54,7 @@ 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.value, rhs_opts.value))
+ Enum_value(lhs_opts), Enum_value(rhs_opts)))
return out
def matmulTN(lhs, rhs):
@@ -85,7 +85,7 @@ def matmulTN(lhs, rhs):
"""
out = Array()
safe_call(backend.get().af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,
- MATPROP.TRANS.value, MATPROP.NONE.value))
+ Enum_value(MATPROP.TRANS), Enum_value(MATPROP.NONE)))
return out
def matmulNT(lhs, rhs):
@@ -116,7 +116,7 @@ def matmulNT(lhs, rhs):
"""
out = Array()
safe_call(backend.get().af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,
- MATPROP.NONE.value, MATPROP.TRANS.value))
+ Enum_value(MATPROP.NONE), Enum_value(MATPROP.TRANS)))
return out
def matmulTT(lhs, rhs):
@@ -147,7 +147,7 @@ def matmulTT(lhs, rhs):
"""
out = Array()
safe_call(backend.get().af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,
- MATPROP.TRANS.value, MATPROP.TRANS.value))
+ Enum_value(MATPROP.TRANS), Enum_value(MATPROP.TRANS)))
return out
def dot(lhs, rhs, lhs_opts=MATPROP.NONE, rhs_opts=MATPROP.NONE):
@@ -188,5 +188,5 @@ 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.value, rhs_opts.value))
+ Enum_value(lhs_opts), Enum_value(rhs_opts)))
return out
diff --git a/arrayfire/data.py b/arrayfire/data.py
index c202aac..41a50b8 100644
--- a/arrayfire/data.py
+++ b/arrayfire/data.py
@@ -52,7 +52,7 @@ 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.value)
+ out.arr = constant_array(val, d0, d1, d2, d3, Enum_value(dtype))
return out
# Store builtin range function to be used later
@@ -116,7 +116,7 @@ def range(d0, d1=None, d2=None, d3=None, dim=0, 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.value))
+ safe_call(backend.get().af_range(ct.pointer(out.arr), 4, ct.pointer(dims), dim, Enum_value(dtype)))
return out
@@ -182,7 +182,7 @@ def iota(d0, d1=None, d2=None, d3=None, dim=-1, tile_dims=None, dtype=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.value))
+ 4, ct.pointer(tdims), Enum_value(dtype)))
return out
def randu(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32):
@@ -219,7 +219,7 @@ 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.value))
+ safe_call(backend.get().af_randu(ct.pointer(out.arr), 4, ct.pointer(dims), Enum_value(dtype)))
return out
def randn(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32):
@@ -257,7 +257,7 @@ 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.value))
+ safe_call(backend.get().af_randn(ct.pointer(out.arr), 4, ct.pointer(dims), Enum_value(dtype)))
return out
def set_seed(seed=0):
@@ -318,7 +318,7 @@ def identity(d0, d1, 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.value))
+ safe_call(backend.get().af_identity(ct.pointer(out.arr), 4, ct.pointer(dims), Enum_value(dtype)))
return out
def diag(a, num=0, extract=True):
diff --git a/arrayfire/graphics.py b/arrayfire/graphics.py
index f2161b1..6594610 100644
--- a/arrayfire/graphics.py
+++ b/arrayfire/graphics.py
@@ -24,7 +24,7 @@ class _Cell(ct.Structure):
self.row = r
self.col = c
self.title = title if title is not None else ct.c_char_p()
- self.cmap = cmap.value
+ self.cmap = Enum_value(cmap)
class Window(object):
"""
diff --git a/arrayfire/image.py b/arrayfire/image.py
index 36a279a..bf48fdd 100644
--- a/arrayfire/image.py
+++ b/arrayfire/image.py
@@ -123,7 +123,7 @@ def resize(image, scale=None, odim0=None, odim1=None, method=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.value))
+ ct.c_longlong(odim1), Enum_value(method)))
return output
@@ -167,7 +167,7 @@ def transform(image, trans_mat, odim0 = 0, odim1 = 0, method=INTERP.NEAREST, is_
safe_call(backend.get().af_transform(ct.pointer(output.arr),
image.arr, trans_mat.arr,
ct.c_longlong(odim0), ct.c_longlong(odim1),
- method.value, is_inverse))
+ Enum_value(method), is_inverse))
return output
def rotate(image, theta, is_crop = True, method = INTERP.NEAREST):
@@ -196,7 +196,7 @@ 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.value))
+ ct.c_double(theta), is_crop, Enum_value(method)))
return output
def translate(image, trans0, trans1, odim0 = 0, odim1 = 0, method = INTERP.NEAREST):
@@ -238,7 +238,7 @@ def translate(image, trans0, trans1, odim0 = 0, odim1 = 0, method = INTERP.NEARE
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.value))
+ ct.c_longlong(odim0), ct.c_longlong(odim1), Enum_value(method)))
return output
def scale(image, scale0, scale1, odim0 = 0, odim1 = 0, method = INTERP.NEAREST):
@@ -280,7 +280,7 @@ 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.value))
+ ct.c_longlong(odim0), ct.c_longlong(odim1), Enum_value(method)))
return output
def skew(image, skew0, skew1, odim0 = 0, odim1 = 0, method = INTERP.NEAREST, is_inverse=True):
@@ -326,7 +326,7 @@ def skew(image, skew0, skew1, odim0 = 0, odim1 = 0, method = INTERP.NEAREST, is_
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.value, is_inverse))
+ Enum_value(method), is_inverse))
return output
@@ -609,7 +609,7 @@ def medfilt(image, w0 = 3, w1 = 3, edge_pad = PAD.ZERO):
output = Array()
safe_call(backend.get().af_medfilt(ct.pointer(output.arr),
image.arr, ct.c_longlong(w0),
- ct.c_longlong(w1), edge_pad.value))
+ ct.c_longlong(w1), Enum_value(edge_pad)))
return output
def minfilt(image, w_len = 3, w_wid = 3, edge_pad = PAD.ZERO):
@@ -641,7 +641,7 @@ 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.value))
+ ct.c_longlong(w_wid), Enum_value(edge_pad)))
return output
def maxfilt(image, w_len = 3, w_wid = 3, edge_pad = PAD.ZERO):
@@ -673,7 +673,7 @@ 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.value))
+ ct.c_longlong(w_wid), Enum_value(edge_pad)))
return output
def regions(image, conn = CONNECTIVITY.FOUR, out_type = Dtype.f32):
@@ -700,7 +700,7 @@ def regions(image, conn = CONNECTIVITY.FOUR, out_type = Dtype.f32):
"""
output = Array()
safe_call(backend.get().af_regions(ct.pointer(output.arr), image.arr,
- conn.value, out_type.value))
+ Enum_value(conn), Enum_value(out_type)))
return output
def sobel_derivatives(image, w_len=3):
@@ -891,5 +891,5 @@ 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.value, from_type.value))
+ Enum_value(to_type), Enum_value(from_type)))
return output
diff --git a/arrayfire/lapack.py b/arrayfire/lapack.py
index 1b15456..2d2c100 100644
--- a/arrayfire/lapack.py
+++ b/arrayfire/lapack.py
@@ -202,7 +202,7 @@ def solve(A, B, options=MATPROP.NONE):
"""
X = Array()
- safe_call(backend.get().af_solve(ct.pointer(X.arr), A.arr, B.arr, options.value))
+ safe_call(backend.get().af_solve(ct.pointer(X.arr), A.arr, B.arr, Enum_value(options)))
return X
def solve_lu(A, P, B, options=MATPROP.NONE):
@@ -230,7 +230,7 @@ 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.value))
+ safe_call(backend.get().af_solve_lu(ct.pointer(X.arr), A.arr, P.arr, B.arr, Enum_value(options)))
return X
def inverse(A, options=MATPROP.NONE):
@@ -260,7 +260,7 @@ def inverse(A, options=MATPROP.NONE):
"""
AI = Array()
- safe_call(backend.get().af_inverse(ct.pointer(AI.arr), A.arr, options.value))
+ safe_call(backend.get().af_inverse(ct.pointer(AI.arr), A.arr, Enum_value(options)))
return AI
def rank(A, tol=1E-5):
@@ -336,6 +336,6 @@ 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.value,
+ safe_call(backend.get().af_norm(ct.pointer(res), A.arr, Enum_value(norm_type),
ct.c_double(p), ct.c_double(q)))
return res.value
diff --git a/arrayfire/library.py b/arrayfire/library.py
index 4f41512..749e5a1 100644
--- a/arrayfire/library.py
+++ b/arrayfire/library.py
@@ -13,7 +13,19 @@ module containing enums and other constants from arrayfire library
import platform
import ctypes as ct
-from enum import Enum
+
+try:
+ from enum import Enum
+
+ def Enum_value(val):
+ return val.value
+
+except:
+ class Enum(object):
+ pass
+
+ def Enum_value(val):
+ return val
class _clibrary(object):
diff --git a/arrayfire/signal.py b/arrayfire/signal.py
index 308fd0b..62b1d91 100644
--- a/arrayfire/signal.py
+++ b/arrayfire/signal.py
@@ -49,7 +49,7 @@ 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.value, ct.c_double(off_grid)))
+ Enum_value(method), ct.c_double(off_grid)))
return output
def approx2(signal, pos0, pos1, method=INTERP.LINEAR, off_grid=0.0):
@@ -91,7 +91,7 @@ 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.value, ct.c_double(off_grid)))
+ pos0.arr, pos1.arr, Enum_value(method), ct.c_double(off_grid)))
return output
def fft(signal, dim0 = None , scale = None):
@@ -507,7 +507,7 @@ def convolve1(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_
"""
output = Array()
safe_call(backend.get().af_convolve1(ct.pointer(output.arr), signal.arr, kernel.arr,
- conv_mode.value, conv_domain.value))
+ Enum_value(conv_mode), Enum_value(conv_domain)))
return output
def convolve2(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_DOMAIN.AUTO):
@@ -555,7 +555,7 @@ def convolve2(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_
"""
output = Array()
safe_call(backend.get().af_convolve2(ct.pointer(output.arr), signal.arr, kernel.arr,
- conv_mode.value, conv_domain.value))
+ Enum_value(conv_mode), Enum_value(conv_domain)))
return output
def convolve3(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_DOMAIN.AUTO):
@@ -601,7 +601,7 @@ def convolve3(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_
"""
output = Array()
safe_call(backend.get().af_convolve3(ct.pointer(output.arr), signal.arr, kernel.arr,
- conv_mode.value, conv_domain.value))
+ Enum_value(conv_mode), Enum_value(conv_domain)))
return output
def convolve(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_DOMAIN.AUTO):
@@ -688,7 +688,7 @@ 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.value))
+ Enum_value(conv_mode)))
return output
def fft_convolve2(signal, kernel, conv_mode = CONV_MODE.DEFAULT):
@@ -732,7 +732,7 @@ 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.value))
+ Enum_value(conv_mode)))
return output
def fft_convolve3(signal, kernel, conv_mode = CONV_MODE.DEFAULT):
@@ -774,7 +774,7 @@ 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.value))
+ Enum_value(conv_mode)))
return output
def fft_convolve(signal, kernel, conv_mode = CONV_MODE.DEFAULT):
diff --git a/arrayfire/util.py b/arrayfire/util.py
index e7ae775..19be9ad 100644
--- a/arrayfire/util.py
+++ b/arrayfire/util.py
@@ -36,12 +36,12 @@ def number_dtype(a):
def implicit_dtype(number, a_dtype):
n_dtype = number_dtype(number)
- n_value = n_dtype.value
+ n_value = Enum_value(n_dtype)
- f64v = Dtype.f64.value
- f32v = Dtype.f32.value
- c32v = Dtype.c32.value
- c64v = Dtype.c64.value
+ f64v = Enum_value(Dtype.f64)
+ f32v = Enum_value(Dtype.f32)
+ c32v = Enum_value(Dtype.c32)
+ c64v = Enum_value(Dtype.c64)
if n_value == f64v and (a_dtype == f32v or a_dtype == c32v):
return Dtype.f32
@@ -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 != ERR.NONE.value):
+ if (af_error != Enum_value(ERR.NONE)):
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,6 +81,7 @@ def get_version():
safe_call(backend.get().af_get_version(ct.pointer(major), ct.pointer(minor), ct.pointer(patch)))
return major,minor,patch
+typecodes = ('f', 'F', 'd', 'D', 'b', 'B', 'i', 'I', 'l', 'L')
to_dtype = {'f' : Dtype.f32,
'd' : Dtype.f64,
'b' : Dtype.b8,
@@ -92,24 +93,24 @@ to_dtype = {'f' : Dtype.f32,
'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}
+to_typecode = {Enum_value(Dtype.f32) : 'f',
+ Enum_value(Dtype.f64) : 'd',
+ Enum_value(Dtype.b8 ) : 'b',
+ Enum_value(Dtype.u8 ) : 'B',
+ Enum_value(Dtype.s32) : 'i',
+ Enum_value(Dtype.u32) : 'I',
+ Enum_value(Dtype.s64) : 'l',
+ Enum_value(Dtype.u64) : 'L',
+ Enum_value(Dtype.c32) : 'F',
+ Enum_value(Dtype.c64) : 'D'}
+
+to_c_type = {Enum_value(Dtype.f32) : ct.c_float,
+ Enum_value(Dtype.f64) : ct.c_double,
+ Enum_value(Dtype.b8 ) : ct.c_char,
+ Enum_value(Dtype.u8 ) : ct.c_ubyte,
+ Enum_value(Dtype.s32) : ct.c_int,
+ Enum_value(Dtype.u32) : ct.c_uint,
+ Enum_value(Dtype.s64) : ct.c_longlong,
+ Enum_value(Dtype.u64) : ct.c_ulonglong,
+ Enum_value(Dtype.c32) : ct.c_float * 2,
+ Enum_value(Dtype.c64) : ct.c_double * 2}
--
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