[python-arrayfire] 115/250: TESTS: Reorganizing the tests folder for easier testing
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:38 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 59601ff9385dbb6d03232e33120fa8475699b935
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date: Wed Sep 9 20:21:47 2015 -0400
TESTS: Reorganizing the tests folder for easier testing
- Fixing the af.display function when called with an alias
---
arrayfire/array.py | 12 +-
tests/__main__.py | 44 ++++++
tests/{simple_blas.py => simple/__init__.py} | 24 +--
tests/simple/_util.py | 50 +++++++
tests/simple/algorithm.py | 78 ++++++++++
tests/simple/arith.py | 210 +++++++++++++++++++++++++++
tests/simple/array_test.py | 56 +++++++
tests/simple/blas.py | 27 ++++
tests/simple/data.py | 79 ++++++++++
tests/simple/device.py | 37 +++++
tests/simple/image.py | 67 +++++++++
tests/simple/index.py | 81 +++++++++++
tests/simple/lapack.py | 77 ++++++++++
tests/simple/signal.py | 80 ++++++++++
tests/simple/statistics.py | 47 ++++++
tests/simple_algorithm.py | 70 ---------
tests/simple_arith.py | 203 --------------------------
tests/simple_array.py | 49 -------
tests/simple_data.py | 72 ---------
tests/simple_device.py | 31 ----
tests/simple_image.py | 60 --------
tests/simple_index.py | 75 ----------
tests/simple_lapack.py | 71 ---------
tests/simple_signal.py | 73 ----------
tests/simple_statistics.py | 40 -----
tests/{simple_blas.py => simple_tests.py} | 20 ++-
26 files changed, 966 insertions(+), 767 deletions(-)
diff --git a/arrayfire/array.py b/arrayfire/array.py
index 7b8e28c..1314c64 100644
--- a/arrayfire/array.py
+++ b/arrayfire/array.py
@@ -1041,6 +1041,12 @@ def display(a):
Multi dimensional arrayfire array
"""
expr = inspect.stack()[1][-2]
- if (expr is not None):
- print('%s' % expr[0].split('display(')[1][:-2])
- safe_call(backend.get().af_print_array(a.arr))
+
+ try:
+ if (expr is not None):
+ st = expr[0].find('(') + 1
+ en = expr[0].rfind(')')
+ print('%s' % expr[0][st:en])
+ safe_call(backend.get().af_print_array(a.arr))
+ except:
+ safe_call(backend.get().af_print_array(a.arr))
diff --git a/tests/__main__.py b/tests/__main__.py
new file mode 100644
index 0000000..5b1e473
--- /dev/null
+++ b/tests/__main__.py
@@ -0,0 +1,44 @@
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import sys
+from simple_tests import *
+
+tests = {}
+tests['simple'] = simple.tests
+
+def assert_valid(name, name_list, name_str):
+ is_valid = any([name == val for val in name_list])
+ if not is_valid:
+ err_str = "The first argument needs to be a %s name\n" % name_str
+ err_str += "List of supported %ss: %s" % (name_str, str(list(name_list)))
+ raise RuntimeError(err_str)
+
+if __name__ == "__main__":
+
+ module_name = None
+ num_args = len(sys.argv)
+
+ if (num_args > 1):
+ module_name = sys.argv[1].lower()
+ assert_valid(sys.argv[1].lower(), tests.keys(), "module")
+
+ if (module_name is None):
+ for name in tests:
+ tests[name].run()
+ else:
+ test = tests[module_name]
+ test_list = None
+
+ if (num_args > 2):
+ test_list = sys.argv[2:]
+ for test_name in test_list:
+ assert_valid(test_name.lower(), test.keys(), "test")
+
+ test.run(test_list)
diff --git a/tests/simple_blas.py b/tests/simple/__init__.py
old mode 100755
new mode 100644
similarity index 54%
copy from tests/simple_blas.py
copy to tests/simple/__init__.py
index 47cc4b6..4651972
--- a/tests/simple_blas.py
+++ b/tests/simple/__init__.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
#######################################################
# Copyright (c) 2015, ArrayFire
# All rights reserved.
@@ -8,14 +7,15 @@
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
-import arrayfire as af
-
-a = af.randu(5,5)
-b = af.randu(5,5)
-
-af.display(af.matmul(a,b))
-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))
+from .algorithm import *
+from .arith import *
+from .array_test import *
+from .blas import *
+from .data import *
+from .device import *
+from .image import *
+from .index import *
+from .lapack import *
+from .signal import *
+from .statistics import *
+from ._util import tests
diff --git a/tests/simple/_util.py b/tests/simple/_util.py
new file mode 100644
index 0000000..911f220
--- /dev/null
+++ b/tests/simple/_util.py
@@ -0,0 +1,50 @@
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import arrayfire as af
+
+def display_func(verbose):
+ if (verbose):
+ return af.display
+ else:
+ def eval_func(foo):
+ res = foo
+ return eval_func
+
+def print_func(verbose):
+ def print_func_impl(*args):
+ if (verbose):
+ print(args)
+ else:
+ res = [args]
+ return print_func_impl
+
+class _simple_test_dict(dict):
+
+ def __init__(self):
+ self.print_str = "Simple %16s: %s"
+ super(_simple_test_dict, self).__init__()
+
+ def run(self, name_list=None, verbose=False):
+ test_list = name_list if name_list is not None else self.keys()
+ for key in test_list:
+
+ try:
+ test = self[key]
+ except:
+ print(self.print_str % (key, "NOTFOUND"))
+ continue
+
+ try:
+ test(verbose)
+ print(self.print_str % (key, "PASSED"))
+ except:
+ print(self.print_str % (key, "FAILED"))
+
+tests = _simple_test_dict()
diff --git a/tests/simple/algorithm.py b/tests/simple/algorithm.py
new file mode 100644
index 0000000..0d75d35
--- /dev/null
+++ b/tests/simple/algorithm.py
@@ -0,0 +1,78 @@
+#!/usr/bin/python
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import arrayfire as af
+from . import _util
+
+def simple_algorithm(verbose = False):
+ display_func = _util.display_func(verbose)
+ print_func = _util.print_func(verbose)
+
+ a = af.randu(3, 3)
+
+ print_func(af.sum(a), af.product(a), af.min(a), af.max(a),
+ af.count(a), af.any_true(a), af.all_true(a))
+
+ display_func(af.sum(a, 0))
+ display_func(af.sum(a, 1))
+
+ display_func(af.product(a, 0))
+ display_func(af.product(a, 1))
+
+ display_func(af.min(a, 0))
+ display_func(af.min(a, 1))
+
+ display_func(af.max(a, 0))
+ display_func(af.max(a, 1))
+
+ display_func(af.count(a, 0))
+ display_func(af.count(a, 1))
+
+ display_func(af.any_true(a, 0))
+ display_func(af.any_true(a, 1))
+
+ display_func(af.all_true(a, 0))
+ display_func(af.all_true(a, 1))
+
+ display_func(af.accum(a, 0))
+ display_func(af.accum(a, 1))
+
+ display_func(af.sort(a, is_ascending=True))
+ display_func(af.sort(a, is_ascending=False))
+
+ val,idx = af.sort_index(a, is_ascending=True)
+ display_func(val)
+ display_func(idx)
+ val,idx = af.sort_index(a, is_ascending=False)
+ display_func(val)
+ display_func(idx)
+
+ b = af.randu(3,3)
+ keys,vals = af.sort_by_key(a, b, is_ascending=True)
+ display_func(keys)
+ display_func(vals)
+ keys,vals = af.sort_by_key(a, b, is_ascending=False)
+ display_func(keys)
+ display_func(vals)
+
+ c = af.randu(5,1)
+ d = af.randu(5,1)
+ cc = af.set_unique(c, is_sorted=False)
+ dd = af.set_unique(af.sort(d), is_sorted=True)
+ display_func(cc)
+ display_func(dd)
+
+ display_func(af.set_union(cc, dd, is_unique=True))
+ display_func(af.set_union(cc, dd, is_unique=False))
+
+ display_func(af.set_intersect(cc, cc, is_unique=True))
+ display_func(af.set_intersect(cc, cc, is_unique=False))
+
+_util.tests['algorithm'] = simple_algorithm
diff --git a/tests/simple/arith.py b/tests/simple/arith.py
new file mode 100644
index 0000000..d70bad1
--- /dev/null
+++ b/tests/simple/arith.py
@@ -0,0 +1,210 @@
+#!/usr/bin/python
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import arrayfire as af
+from . import _util
+
+def simple_arith(verbose = False):
+ display_func = _util.display_func(verbose)
+ print_func = _util.print_func(verbose)
+
+ a = af.randu(3,3,dtype=af.Dtype.u32)
+ b = af.constant(4, 3, 3, dtype=af.Dtype.u32)
+ display_func(a)
+ display_func(b)
+
+ c = a + b
+ d = a
+ d += b
+
+ display_func(c)
+ display_func(d)
+ display_func(a + 2)
+ display_func(3 + a)
+
+
+ c = a - b
+ d = a
+ d -= b
+
+ display_func(c)
+ display_func(d)
+ display_func(a - 2)
+ display_func(3 - a)
+
+ c = a * b
+ d = a
+ d *= b
+
+ display_func(c * 2)
+ display_func(3 * d)
+ display_func(a * 2)
+ display_func(3 * a)
+
+ c = a / b
+ d = a
+ d /= b
+
+ display_func(c / 2.0)
+ display_func(3.0 / d)
+ display_func(a / 2)
+ display_func(3 / a)
+
+ c = a % b
+ d = a
+ d %= b
+
+ display_func(c % 2.0)
+ display_func(3.0 % d)
+ display_func(a % 2)
+ display_func(3 % a)
+
+ c = a ** b
+ d = a
+ d **= b
+
+ display_func(c ** 2.0)
+ display_func(3.0 ** d)
+ display_func(a ** 2)
+ display_func(3 ** a)
+
+ display_func(a < b)
+ display_func(a < 0.5)
+ display_func(0.5 < a)
+
+ display_func(a <= b)
+ display_func(a <= 0.5)
+ display_func(0.5 <= a)
+
+ display_func(a > b)
+ display_func(a > 0.5)
+ display_func(0.5 > a)
+
+ display_func(a >= b)
+ display_func(a >= 0.5)
+ display_func(0.5 >= a)
+
+ display_func(a != b)
+ display_func(a != 0.5)
+ display_func(0.5 != a)
+
+ display_func(a == b)
+ display_func(a == 0.5)
+ display_func(0.5 == a)
+
+ display_func(a & b)
+ display_func(a & 2)
+ c = a
+ c &= 2
+ display_func(c)
+
+ display_func(a | b)
+ display_func(a | 2)
+ c = a
+ c |= 2
+ display_func(c)
+
+ display_func(a >> b)
+ display_func(a >> 2)
+ c = a
+ c >>= 2
+ display_func(c)
+
+ display_func(a << b)
+ display_func(a << 2)
+ c = a
+ c <<= 2
+ display_func(c)
+
+ display_func(-a)
+ display_func(+a)
+ display_func(~a)
+ display_func(a)
+
+ display_func(af.cast(a, af.Dtype.c32))
+ display_func(af.maxof(a,b))
+ display_func(af.minof(a,b))
+ display_func(af.rem(a,b))
+
+ a = af.randu(3,3) - 0.5
+ b = af.randu(3,3) - 0.5
+
+ display_func(af.abs(a))
+ display_func(af.arg(a))
+ display_func(af.sign(a))
+ display_func(af.round(a))
+ display_func(af.trunc(a))
+ display_func(af.floor(a))
+ display_func(af.ceil(a))
+ display_func(af.hypot(a, b))
+ display_func(af.sin(a))
+ display_func(af.cos(a))
+ display_func(af.tan(a))
+ display_func(af.asin(a))
+ display_func(af.acos(a))
+ display_func(af.atan(a))
+ display_func(af.atan2(a, b))
+
+ c = af.cplx(a)
+ d = af.cplx(a,b)
+ display_func(c)
+ display_func(d)
+ display_func(af.real(d))
+ display_func(af.imag(d))
+ display_func(af.conjg(d))
+
+ display_func(af.sinh(a))
+ display_func(af.cosh(a))
+ display_func(af.tanh(a))
+ display_func(af.asinh(a))
+ display_func(af.acosh(a))
+ display_func(af.atanh(a))
+
+ a = af.abs(a)
+ b = af.abs(b)
+
+ display_func(af.root(a, b))
+ display_func(af.pow(a, b))
+ display_func(af.pow2(a))
+ display_func(af.exp(a))
+ display_func(af.expm1(a))
+ display_func(af.erf(a))
+ display_func(af.erfc(a))
+ display_func(af.log(a))
+ display_func(af.log1p(a))
+ display_func(af.log10(a))
+ display_func(af.log2(a))
+ display_func(af.sqrt(a))
+ display_func(af.cbrt(a))
+
+ a = af.round(5 * af.randu(3,3) - 1)
+ b = af.round(5 * af.randu(3,3) - 1)
+
+ display_func(af.factorial(a))
+ display_func(af.tgamma(a))
+ display_func(af.lgamma(a))
+ display_func(af.iszero(a))
+ display_func(af.isinf(a/b))
+ display_func(af.isnan(a/a))
+
+ a = af.randu(5, 1)
+ b = af.randu(1, 5)
+ c = af.broadcast(lambda x,y: x+y, a, b)
+ display_func(a)
+ display_func(b)
+ display_func(c)
+
+ @af.broadcast
+ def test_add(aa, bb):
+ return aa + bb
+
+ display_func(test_add(a, b))
+
+_util.tests['arith'] = simple_arith
diff --git a/tests/simple/array_test.py b/tests/simple/array_test.py
new file mode 100644
index 0000000..d7652b5
--- /dev/null
+++ b/tests/simple/array_test.py
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import arrayfire as af
+import array as host
+from . import _util
+
+def simple_array(verbose=False):
+ display_func = _util.display_func(verbose)
+ print_func = _util.print_func(verbose)
+
+ a = af.Array([1, 2, 3])
+ display_func(a)
+ print_func(a.elements(), a.type(), a.dims(), a.numdims())
+ print_func(a.is_empty(), a.is_scalar(), a.is_column(), a.is_row())
+ print_func(a.is_complex(), a.is_real(), a.is_double(), a.is_single())
+ print_func(a.is_real_floating(), a.is_floating(), a.is_integer(), a.is_bool())
+
+
+ a = af.Array(host.array('i', [4, 5, 6]))
+ display_func(a)
+ print_func(a.elements(), a.type(), a.dims(), a.numdims())
+ print_func(a.is_empty(), a.is_scalar(), a.is_column(), a.is_row())
+ print_func(a.is_complex(), a.is_real(), a.is_double(), a.is_single())
+ print_func(a.is_real_floating(), a.is_floating(), a.is_integer(), a.is_bool())
+
+ a = af.Array(host.array('l', [7, 8, 9] * 3), (3,3))
+ display_func(a)
+ print_func(a.elements(), a.type(), a.dims(), a.numdims())
+ print_func(a.is_empty(), a.is_scalar(), a.is_column(), a.is_row())
+ print_func(a.is_complex(), a.is_real(), a.is_double(), a.is_single())
+ print_func(a.is_real_floating(), a.is_floating(), a.is_integer(), a.is_bool())
+
+ c = a.to_ctype()
+ for n in range(a.elements()):
+ print_func(c[n])
+
+ c,s = a.to_ctype(True, True)
+ for n in range(a.elements()):
+ print_func(c[n])
+ print_func(s)
+
+ arr = a.to_array()
+ lst = a.to_list(True)
+
+ print_func(arr)
+ print_func(lst)
+
+_util.tests['array'] = simple_array
diff --git a/tests/simple/blas.py b/tests/simple/blas.py
new file mode 100644
index 0000000..fd58d18
--- /dev/null
+++ b/tests/simple/blas.py
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import arrayfire as af
+from . import _util
+
+def simple_blas(verbose=False):
+ display_func = _util.display_func(verbose)
+ print_func = _util.print_func(verbose)
+ a = af.randu(5,5)
+ b = af.randu(5,5)
+
+ display_func(af.matmul(a,b))
+ display_func(af.matmul(a,b,af.MATPROP.TRANS))
+ display_func(af.matmul(a,b,af.MATPROP.NONE, af.MATPROP.TRANS))
+
+ b = af.randu(5,1)
+ display_func(af.dot(b,b))
+
+_util.tests['blas'] = simple_blas
diff --git a/tests/simple/data.py b/tests/simple/data.py
new file mode 100644
index 0000000..b19b388
--- /dev/null
+++ b/tests/simple/data.py
@@ -0,0 +1,79 @@
+#!/usr/bin/python
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import arrayfire as af
+from . import _util
+
+def simple_data(verbose=False):
+ display_func = _util.display_func(verbose)
+ print_func = _util.print_func(verbose)
+
+ display_func(af.constant(100, 3,3, dtype=af.Dtype.f32))
+ display_func(af.constant(25, 3,3, dtype=af.Dtype.c32))
+ display_func(af.constant(2**50, 3,3, dtype=af.Dtype.s64))
+ display_func(af.constant(2+3j, 3,3))
+ display_func(af.constant(3+5j, 3,3, dtype=af.Dtype.c32))
+
+ display_func(af.range(3, 3))
+ display_func(af.iota(3, 3, tile_dims=(2,2)))
+
+ display_func(af.randu(3, 3, 1, 2))
+ display_func(af.randu(3, 3, 1, 2, af.Dtype.b8))
+ display_func(af.randu(3, 3, dtype=af.Dtype.c32))
+
+ display_func(af.randn(3, 3, 1, 2))
+ display_func(af.randn(3, 3, dtype=af.Dtype.c32))
+
+ af.set_seed(1024)
+ assert(af.get_seed() == 1024)
+
+ display_func(af.identity(3, 3, 1, 2, af.Dtype.b8))
+ display_func(af.identity(3, 3, dtype=af.Dtype.c32))
+
+ a = af.randu(3, 4)
+ b = af.diag(a, extract=True)
+ c = af.diag(a, 1, extract=True)
+
+ display_func(a)
+ display_func(b)
+ display_func(c)
+
+ display_func(af.diag(b, extract = False))
+ display_func(af.diag(c, 1, extract = False))
+
+ display_func(af.join(0, a, a))
+ display_func(af.join(1, a, a, a))
+
+ display_func(af.tile(a, 2, 2))
+
+
+ display_func(af.reorder(a, 1, 0))
+
+ display_func(af.shift(a, -1, 1))
+
+ display_func(af.moddims(a, 6, 2))
+
+ display_func(af.flat(a))
+
+ display_func(af.flip(a, 0))
+ display_func(af.flip(a, 1))
+
+ display_func(af.lower(a, False))
+ display_func(af.lower(a, True))
+
+ display_func(af.upper(a, False))
+ display_func(af.upper(a, True))
+
+ a = af.randu(5,5)
+ display_func(af.transpose(a))
+ af.transpose_inplace(a)
+ display_func(a)
+
+_util.tests['data'] = simple_data
diff --git a/tests/simple/device.py b/tests/simple/device.py
new file mode 100644
index 0000000..250e093
--- /dev/null
+++ b/tests/simple/device.py
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import arrayfire as af
+from . import _util
+
+def simple_device(verbose=False):
+ display_func = _util.display_func(verbose)
+ print_func = _util.print_func(verbose)
+ print_func(af.device_info())
+ print_func(af.get_device_count())
+ print_func(af.is_dbl_supported())
+ af.sync()
+
+ for k in range(af.get_device_count()):
+ af.set_device(k)
+ dev = af.get_device()
+ assert(k == dev)
+
+ print_func(af.is_dbl_supported(k))
+
+ mem_info_old = af.device_mem_info()
+
+ a = af.randu(100, 100)
+ af.sync(dev)
+ mem_info = af.device_mem_info()
+ assert(mem_info['alloc']['buffers'] == 1 + mem_info_old['alloc']['buffers'])
+ assert(mem_info[ 'lock']['buffers'] == 1 + mem_info_old[ 'lock']['buffers'])
+
+_util.tests['device'] = simple_device
diff --git a/tests/simple/image.py b/tests/simple/image.py
new file mode 100644
index 0000000..31f0abd
--- /dev/null
+++ b/tests/simple/image.py
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import arrayfire as af
+from . import _util
+
+def simple_image(verbose = False):
+ display_func = _util.display_func(verbose)
+ print_func = _util.print_func(verbose)
+
+ a = 10 * af.randu(6, 6)
+ a3 = 10 * af.randu(5,5,3)
+
+ dx,dy = af.gradient(a)
+ display_func(dx)
+ display_func(dy)
+
+ display_func(af.resize(a, scale=0.5))
+ display_func(af.resize(a, odim0=8, odim1=8))
+
+ t = af.randu(3,2)
+ display_func(af.transform(a, t))
+ display_func(af.rotate(a, 3.14))
+ display_func(af.translate(a, 1, 1))
+ display_func(af.scale(a, 1.2, 1.2, 7, 7))
+ display_func(af.skew(a, 0.02, 0.02))
+ h = af.histogram(a, 3)
+ display_func(h)
+ display_func(af.hist_equal(a, h))
+
+ display_func(af.dilate(a))
+ display_func(af.erode(a))
+
+ display_func(af.dilate3(a3))
+ display_func(af.erode3(a3))
+
+ display_func(af.bilateral(a, 1, 2))
+ display_func(af.mean_shift(a, 1, 2, 3))
+
+ display_func(af.medfilt(a))
+ display_func(af.minfilt(a))
+ display_func(af.maxfilt(a))
+
+ display_func(af.regions(af.round(a) > 3))
+
+ dx,dy = af.sobel_derivatives(a)
+ display_func(dx)
+ display_func(dy)
+ display_func(af.sobel_filter(a))
+
+ ac = af.gray2rgb(a)
+ display_func(ac)
+ display_func(af.rgb2gray(ac))
+ ah = af.rgb2hsv(ac)
+ display_func(ah)
+ display_func(af.hsv2rgb(ah))
+
+ display_func(af.color_space(a, af.CSPACE.RGB, af.CSPACE.GRAY))
+
+_util.tests['image'] = simple_image
diff --git a/tests/simple/index.py b/tests/simple/index.py
new file mode 100644
index 0000000..7ebde6e
--- /dev/null
+++ b/tests/simple/index.py
@@ -0,0 +1,81 @@
+#!/usr/bin/python
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+import arrayfire as af
+from arrayfire import ParallelRange
+import array as host
+from . import _util
+
+def simple_index(verbose=False):
+ display_func = _util.display_func(verbose)
+ print_func = _util.print_func(verbose)
+ a = af.randu(5, 5)
+ display_func(a)
+ b = af.Array(a)
+ display_func(b)
+
+ c = a.copy()
+ display_func(c)
+ display_func(a[0,0])
+ display_func(a[0])
+ display_func(a[:])
+ display_func(a[:,:])
+ display_func(a[0:3,])
+ display_func(a[-2:-1,-1])
+ display_func(a[0:5])
+ display_func(a[0:5:2])
+
+ idx = af.Array(host.array('i', [0, 3, 2]))
+ display_func(idx)
+ aa = a[idx]
+ display_func(aa)
+
+ a[0] = 1
+ display_func(a)
+ a[0] = af.randu(1, 5)
+ display_func(a)
+ a[:] = af.randu(5,5)
+ display_func(a)
+ a[:,-1] = af.randu(5,1)
+ display_func(a)
+ a[0:5:2] = af.randu(3, 5)
+ display_func(a)
+ a[idx, idx] = af.randu(3,3)
+ display_func(a)
+
+
+ a = af.randu(5,1)
+ b = af.randu(5,1)
+ display_func(a)
+ display_func(b)
+ for ii in ParallelRange(1,3):
+ a[ii] = b[ii]
+
+ display_func(a)
+
+ for ii in ParallelRange(2,5):
+ b[ii] = 2
+ display_func(b)
+
+ a = af.randu(3,2)
+ rows = af.constant(0, 1, dtype=af.Dtype.s32)
+ b = a[:,rows]
+ display_func(b)
+ for r in rows:
+ display_func(r)
+ display_func(b[:,r])
+
+ a = af.randu(3)
+ c = af.randu(3)
+ b = af.constant(1,3,dtype=af.Dtype.b8)
+ display_func(a)
+ a[b] = c
+ display_func(a)
+
+_util.tests['index'] = simple_index
diff --git a/tests/simple/lapack.py b/tests/simple/lapack.py
new file mode 100644
index 0000000..fa2731f
--- /dev/null
+++ b/tests/simple/lapack.py
@@ -0,0 +1,77 @@
+#!/usr/bin/python
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+import arrayfire as af
+from . import _util
+
+def simple_lapack(verbose=False):
+ display_func = _util.display_func(verbose)
+ print_func = _util.print_func(verbose)
+ a = af.randu(5,5)
+
+ l,u,p = af.lu(a)
+
+ display_func(l)
+ display_func(u)
+ display_func(p)
+
+ p = af.lu_inplace(a, "full")
+
+ display_func(a)
+ display_func(p)
+
+ a = af.randu(5,3)
+
+ q,r,t = af.qr(a)
+
+ display_func(q)
+ display_func(r)
+ display_func(t)
+
+ af.qr_inplace(a)
+
+ display_func(a)
+
+ a = af.randu(5, 5)
+ a = af.matmulTN(a, a) + 10 * af.identity(5,5)
+
+ R,info = af.cholesky(a)
+ display_func(R)
+ print_func(info)
+
+ af.cholesky_inplace(a)
+ display_func(a)
+
+ a = af.randu(5,5)
+ ai = af.inverse(a)
+
+ display_func(a)
+ display_func(ai)
+
+ x0 = af.randu(5, 3)
+ b = af.matmul(a, x0)
+ x1 = af.solve(a, b)
+
+ display_func(x0)
+ display_func(x1)
+
+ p = af.lu_inplace(a)
+
+ x2 = af.solve_lu(a, p, b)
+
+ display_func(x2)
+
+ print_func(af.rank(a))
+ print_func(af.det(a))
+ print_func(af.norm(a, af.NORM.EUCLID))
+ print_func(af.norm(a, af.NORM.MATRIX_1))
+ print_func(af.norm(a, af.NORM.MATRIX_INF))
+ print_func(af.norm(a, af.NORM.MATRIX_L_PQ, 1, 1))
+
+_util.tests['lapack'] = simple_lapack
diff --git a/tests/simple/signal.py b/tests/simple/signal.py
new file mode 100644
index 0000000..b1d9970
--- /dev/null
+++ b/tests/simple/signal.py
@@ -0,0 +1,80 @@
+#!/usr/bin/python
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import arrayfire as af
+from . import _util
+
+def simple_signal(verbose=False):
+ display_func = _util.display_func(verbose)
+ print_func = _util.print_func(verbose)
+
+ a = af.randu(10, 1)
+ pos0 = af.randu(10) * 10
+ display_func(af.approx1(a, pos0))
+
+ a = af.randu(3, 3)
+ pos0 = af.randu(3, 3) * 10
+ pos1 = af.randu(3, 3) * 10
+
+ display_func(af.approx2(a, pos0, pos1))
+
+ a = af.randu(8, 1)
+ display_func(a)
+
+ display_func(af.fft(a))
+ display_func(af.dft(a))
+ display_func(af.real(af.ifft(af.fft(a))))
+ display_func(af.real(af.idft(af.dft(a))))
+
+ a = af.randu(4, 4)
+ display_func(a)
+
+ display_func(af.fft2(a))
+ display_func(af.dft(a))
+ display_func(af.real(af.ifft2(af.fft2(a))))
+ display_func(af.real(af.idft(af.dft(a))))
+
+ a = af.randu(4, 4, 2)
+ display_func(a)
+
+ display_func(af.fft3(a))
+ display_func(af.dft(a))
+ display_func(af.real(af.ifft3(af.fft3(a))))
+ display_func(af.real(af.idft(af.dft(a))))
+
+ a = af.randu(10, 1)
+ b = af.randu(3, 1)
+ display_func(af.convolve1(a, b))
+ display_func(af.fft_convolve1(a, b))
+ display_func(af.convolve(a, b))
+ display_func(af.fft_convolve(a, b))
+
+ a = af.randu(5, 5)
+ b = af.randu(3, 3)
+ display_func(af.convolve2(a, b))
+ display_func(af.fft_convolve2(a, b))
+ display_func(af.convolve(a, b))
+ display_func(af.fft_convolve(a, b))
+
+ a = af.randu(5, 5, 3)
+ b = af.randu(3, 3, 2)
+ display_func(af.convolve3(a, b))
+ display_func(af.fft_convolve3(a, b))
+ display_func(af.convolve(a, b))
+ display_func(af.fft_convolve(a, b))
+
+
+ b = af.randu(3, 1)
+ x = af.randu(10, 1)
+ a = af.randu(2, 1)
+ display_func(af.fir(b, x))
+ display_func(af.iir(b, a, x))
+
+_util.tests['signal'] = simple_signal
diff --git a/tests/simple/statistics.py b/tests/simple/statistics.py
new file mode 100644
index 0000000..2b90998
--- /dev/null
+++ b/tests/simple/statistics.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+import arrayfire as af
+from . import _util
+
+def simple_statistics(verbose=False):
+ display_func = _util.display_func(verbose)
+ print_func = _util.print_func(verbose)
+
+ a = af.randu(5, 5)
+ b = af.randu(5, 5)
+ w = af.randu(5, 1)
+
+ display_func(af.mean(a, dim=0))
+ display_func(af.mean(a, weights=w, dim=0))
+ print_func(af.mean(a))
+ print_func(af.mean(a, weights=w))
+
+ display_func(af.var(a, dim=0))
+ display_func(af.var(a, isbiased=True, dim=0))
+ display_func(af.var(a, weights=w, dim=0))
+ print_func(af.var(a))
+ print_func(af.var(a, isbiased=True))
+ print_func(af.var(a, weights=w))
+
+ display_func(af.stdev(a, dim=0))
+ print_func(af.stdev(a))
+
+ display_func(af.var(a, dim=0))
+ display_func(af.var(a, isbiased=True, dim=0))
+ print_func(af.var(a))
+ print_func(af.var(a, isbiased=True))
+
+ display_func(af.median(a, dim=0))
+ print_func(af.median(w))
+
+ print_func(af.corrcoef(a, b))
+
+_util.tests['statistics'] = simple_statistics
diff --git a/tests/simple_algorithm.py b/tests/simple_algorithm.py
deleted file mode 100755
index 71c95dc..0000000
--- a/tests/simple_algorithm.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/python
-#######################################################
-# Copyright (c) 2015, ArrayFire
-# All rights reserved.
-#
-# This file is distributed under 3-clause BSD license.
-# The complete license agreement can be obtained at:
-# http://arrayfire.com/licenses/BSD-3-Clause
-########################################################
-
-import arrayfire as af
-
-a = af.randu(3, 3)
-
-print(af.sum(a), af.product(a), af.min(a), af.max(a), af.count(a), af.any_true(a), af.all_true(a))
-
-af.display(af.sum(a, 0))
-af.display(af.sum(a, 1))
-
-af.display(af.product(a, 0))
-af.display(af.product(a, 1))
-
-af.display(af.min(a, 0))
-af.display(af.min(a, 1))
-
-af.display(af.max(a, 0))
-af.display(af.max(a, 1))
-
-af.display(af.count(a, 0))
-af.display(af.count(a, 1))
-
-af.display(af.any_true(a, 0))
-af.display(af.any_true(a, 1))
-
-af.display(af.all_true(a, 0))
-af.display(af.all_true(a, 1))
-
-af.display(af.accum(a, 0))
-af.display(af.accum(a, 1))
-
-af.display(af.sort(a, is_ascending=True))
-af.display(af.sort(a, is_ascending=False))
-
-val,idx = af.sort_index(a, is_ascending=True)
-af.display(val)
-af.display(idx)
-val,idx = af.sort_index(a, is_ascending=False)
-af.display(val)
-af.display(idx)
-
-b = af.randu(3,3)
-keys,vals = af.sort_by_key(a, b, is_ascending=True)
-af.display(keys)
-af.display(vals)
-keys,vals = af.sort_by_key(a, b, is_ascending=False)
-af.display(keys)
-af.display(vals)
-
-c = af.randu(5,1)
-d = af.randu(5,1)
-cc = af.set_unique(c, is_sorted=False)
-dd = af.set_unique(af.sort(d), is_sorted=True)
-af.display(cc)
-af.display(dd)
-
-af.display(af.set_union(cc, dd, is_unique=True))
-af.display(af.set_union(cc, dd, is_unique=False))
-
-af.display(af.set_intersect(cc, cc, is_unique=True))
-af.display(af.set_intersect(cc, cc, is_unique=False))
diff --git a/tests/simple_arith.py b/tests/simple_arith.py
deleted file mode 100755
index c2ea3d1..0000000
--- a/tests/simple_arith.py
+++ /dev/null
@@ -1,203 +0,0 @@
-#!/usr/bin/python
-#######################################################
-# Copyright (c) 2015, ArrayFire
-# All rights reserved.
-#
-# This file is distributed under 3-clause BSD license.
-# The complete license agreement can be obtained at:
-# http://arrayfire.com/licenses/BSD-3-Clause
-########################################################
-
-import arrayfire as af
-
-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)
-
-c = a + b
-d = a
-d += b
-
-af.display(c)
-af.display(d)
-af.display(a + 2)
-af.display(3 + a)
-
-
-c = a - b
-d = a
-d -= b
-
-af.display(c)
-af.display(d)
-af.display(a - 2)
-af.display(3 - a)
-
-c = a * b
-d = a
-d *= b
-
-af.display(c * 2)
-af.display(3 * d)
-af.display(a * 2)
-af.display(3 * a)
-
-c = a / b
-d = a
-d /= b
-
-af.display(c / 2.0)
-af.display(3.0 / d)
-af.display(a / 2)
-af.display(3 / a)
-
-c = a % b
-d = a
-d %= b
-
-af.display(c % 2.0)
-af.display(3.0 % d)
-af.display(a % 2)
-af.display(3 % a)
-
-c = a ** b
-d = a
-d **= b
-
-af.display(c ** 2.0)
-af.display(3.0 ** d)
-af.display(a ** 2)
-af.display(3 ** a)
-
-af.display(a < b)
-af.display(a < 0.5)
-af.display(0.5 < a)
-
-af.display(a <= b)
-af.display(a <= 0.5)
-af.display(0.5 <= a)
-
-af.display(a > b)
-af.display(a > 0.5)
-af.display(0.5 > a)
-
-af.display(a >= b)
-af.display(a >= 0.5)
-af.display(0.5 >= a)
-
-af.display(a != b)
-af.display(a != 0.5)
-af.display(0.5 != a)
-
-af.display(a == b)
-af.display(a == 0.5)
-af.display(0.5 == a)
-
-af.display(a & b)
-af.display(a & 2)
-c = a
-c &= 2
-af.display(c)
-
-af.display(a | b)
-af.display(a | 2)
-c = a
-c |= 2
-af.display(c)
-
-af.display(a >> b)
-af.display(a >> 2)
-c = a
-c >>= 2
-af.display(c)
-
-af.display(a << b)
-af.display(a << 2)
-c = a
-c <<= 2
-af.display(c)
-
-af.display(-a)
-af.display(+a)
-af.display(~a)
-af.display(a)
-
-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))
-
-a = af.randu(3,3) - 0.5
-b = af.randu(3,3) - 0.5
-
-af.display(af.abs(a))
-af.display(af.arg(a))
-af.display(af.sign(a))
-af.display(af.round(a))
-af.display(af.trunc(a))
-af.display(af.floor(a))
-af.display(af.ceil(a))
-af.display(af.hypot(a, b))
-af.display(af.sin(a))
-af.display(af.cos(a))
-af.display(af.tan(a))
-af.display(af.asin(a))
-af.display(af.acos(a))
-af.display(af.atan(a))
-af.display(af.atan2(a, b))
-
-c = af.cplx(a)
-d = af.cplx(a,b)
-af.display(c)
-af.display(d)
-af.display(af.real(d))
-af.display(af.imag(d))
-af.display(af.conjg(d))
-
-af.display(af.sinh(a))
-af.display(af.cosh(a))
-af.display(af.tanh(a))
-af.display(af.asinh(a))
-af.display(af.acosh(a))
-af.display(af.atanh(a))
-
-a = af.abs(a)
-b = af.abs(b)
-
-af.display(af.root(a, b))
-af.display(af.pow(a, b))
-af.display(af.pow2(a))
-af.display(af.exp(a))
-af.display(af.expm1(a))
-af.display(af.erf(a))
-af.display(af.erfc(a))
-af.display(af.log(a))
-af.display(af.log1p(a))
-af.display(af.log10(a))
-af.display(af.log2(a))
-af.display(af.sqrt(a))
-af.display(af.cbrt(a))
-
-a = af.round(5 * af.randu(3,3) - 1)
-b = af.round(5 * af.randu(3,3) - 1)
-
-af.display(af.factorial(a))
-af.display(af.tgamma(a))
-af.display(af.lgamma(a))
-af.display(af.iszero(a))
-af.display(af.isinf(a/b))
-af.display(af.isnan(a/a))
-
-a = af.randu(5, 1)
-b = af.randu(1, 5)
-c = af.broadcast(lambda x,y: x+y, a, b)
-af.display(a)
-af.display(b)
-af.display(c)
-
- at af.broadcast
-def test_add(aa, bb):
- return aa + bb
-
-af.display(test_add(a, b))
diff --git a/tests/simple_array.py b/tests/simple_array.py
deleted file mode 100755
index f8474f2..0000000
--- a/tests/simple_array.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/python
-#######################################################
-# Copyright (c) 2015, ArrayFire
-# All rights reserved.
-#
-# This file is distributed under 3-clause BSD license.
-# The complete license agreement can be obtained at:
-# http://arrayfire.com/licenses/BSD-3-Clause
-########################################################
-
-import arrayfire as af
-import array as host
-
-a = af.Array([1, 2, 3])
-af.display(a)
-print(a.elements(), a.type(), a.dims(), a.numdims())
-print(a.is_empty(), a.is_scalar(), a.is_column(), a.is_row())
-print(a.is_complex(), a.is_real(), a.is_double(), a.is_single())
-print(a.is_real_floating(), a.is_floating(), a.is_integer(), a.is_bool())
-
-
-a = af.Array(host.array('i', [4, 5, 6]))
-af.display(a)
-print(a.elements(), a.type(), a.dims(), a.numdims())
-print(a.is_empty(), a.is_scalar(), a.is_column(), a.is_row())
-print(a.is_complex(), a.is_real(), a.is_double(), a.is_single())
-print(a.is_real_floating(), a.is_floating(), a.is_integer(), a.is_bool())
-
-a = af.Array(host.array('l', [7, 8, 9] * 3), (3,3))
-af.display(a)
-print(a.elements(), a.type(), a.dims(), a.numdims())
-print(a.is_empty(), a.is_scalar(), a.is_column(), a.is_row())
-print(a.is_complex(), a.is_real(), a.is_double(), a.is_single())
-print(a.is_real_floating(), a.is_floating(), a.is_integer(), a.is_bool())
-
-c = a.to_ctype()
-for n in range(a.elements()):
- print(c[n])
-
-c,s = a.to_ctype(True, True)
-for n in range(a.elements()):
- print(c[n])
-print(s)
-
-arr = a.to_array()
-lst = a.to_list(True)
-
-print(arr)
-print(lst)
diff --git a/tests/simple_data.py b/tests/simple_data.py
deleted file mode 100755
index 71fa5ac..0000000
--- a/tests/simple_data.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/python
-#######################################################
-# Copyright (c) 2015, ArrayFire
-# All rights reserved.
-#
-# This file is distributed under 3-clause BSD license.
-# The complete license agreement can be obtained at:
-# http://arrayfire.com/licenses/BSD-3-Clause
-########################################################
-
-import arrayfire as af
-
-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.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.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.Dtype.c32))
-
-af.set_seed(1024)
-assert(af.get_seed() == 1024)
-
-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)
-c = af.diag(a, 1, extract=True)
-
-af.display(a)
-af.display(b)
-af.display(c)
-
-af.display(af.diag(b, extract = False))
-af.display(af.diag(c, 1, extract = False))
-
-af.display(af.join(0, a, a))
-af.display(af.join(1, a, a, a))
-
-af.display(af.tile(a, 2, 2))
-
-
-af.display(af.reorder(a, 1, 0))
-
-af.display(af.shift(a, -1, 1))
-
-af.display(af.moddims(a, 6, 2))
-
-af.display(af.flat(a))
-
-af.display(af.flip(a, 0))
-af.display(af.flip(a, 1))
-
-af.display(af.lower(a, False))
-af.display(af.lower(a, True))
-
-af.display(af.upper(a, False))
-af.display(af.upper(a, True))
-
-a = af.randu(5,5)
-af.display(af.transpose(a))
-af.transpose_inplace(a)
-af.display(a)
diff --git a/tests/simple_device.py b/tests/simple_device.py
deleted file mode 100755
index 69acdba..0000000
--- a/tests/simple_device.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/python
-#######################################################
-# Copyright (c) 2015, ArrayFire
-# All rights reserved.
-#
-# This file is distributed under 3-clause BSD license.
-# The complete license agreement can be obtained at:
-# http://arrayfire.com/licenses/BSD-3-Clause
-########################################################
-
-import arrayfire as af
-
-af.info()
-print(af.device_info())
-print(af.get_device_count())
-print(af.is_dbl_supported())
-af.sync()
-
-print('starting the loop')
-for k in range(af.get_device_count()):
- af.set_device(k)
- dev = af.get_device()
- assert(k == dev)
-
- print(af.is_dbl_supported(k))
-
- a = af.randu(100, 100)
- af.sync(dev)
- mem_info = af.device_mem_info()
- assert(mem_info['alloc']['buffers'] == 1)
- assert(mem_info[ 'lock']['buffers'] == 1)
diff --git a/tests/simple_image.py b/tests/simple_image.py
deleted file mode 100755
index cfbbc73..0000000
--- a/tests/simple_image.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/python
-#######################################################
-# Copyright (c) 2015, ArrayFire
-# All rights reserved.
-#
-# This file is distributed under 3-clause BSD license.
-# The complete license agreement can be obtained at:
-# http://arrayfire.com/licenses/BSD-3-Clause
-########################################################
-
-import arrayfire as af
-
-a = 10 * af.randu(6, 6)
-a3 = 10 * af.randu(5,5,3)
-
-dx,dy = af.gradient(a)
-af.display(dx)
-af.display(dy)
-
-af.display(af.resize(a, scale=0.5))
-af.display(af.resize(a, odim0=8, odim1=8))
-
-t = af.randu(3,2)
-af.display(af.transform(a, t))
-af.display(af.rotate(a, 3.14))
-af.display(af.translate(a, 1, 1))
-af.display(af.scale(a, 1.2, 1.2, 7, 7))
-af.display(af.skew(a, 0.02, 0.02))
-h = af.histogram(a, 3)
-af.display(h)
-af.display(af.hist_equal(a, h))
-
-af.display(af.dilate(a))
-af.display(af.erode(a))
-
-af.display(af.dilate3(a3))
-af.display(af.erode3(a3))
-
-af.display(af.bilateral(a, 1, 2))
-af.display(af.mean_shift(a, 1, 2, 3))
-
-af.display(af.medfilt(a))
-af.display(af.minfilt(a))
-af.display(af.maxfilt(a))
-
-af.display(af.regions(af.round(a) > 3))
-
-dx,dy = af.sobel_derivatives(a)
-af.display(dx)
-af.display(dy)
-af.display(af.sobel_filter(a))
-
-ac = af.gray2rgb(a)
-af.display(ac)
-af.display(af.rgb2gray(ac))
-ah = af.rgb2hsv(ac)
-af.display(ah)
-af.display(af.hsv2rgb(ah))
-
-af.display(af.color_space(a, af.CSPACE.RGB, af.CSPACE.GRAY))
diff --git a/tests/simple_index.py b/tests/simple_index.py
deleted file mode 100755
index b7100f4..0000000
--- a/tests/simple_index.py
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/python
-#######################################################
-# Copyright (c) 2015, ArrayFire
-# All rights reserved.
-#
-# This file is distributed under 3-clause BSD license.
-# The complete license agreement can be obtained at:
-# http://arrayfire.com/licenses/BSD-3-Clause
-########################################################
-import arrayfire as af
-from arrayfire import ParallelRange
-import array as host
-
-a = af.randu(5, 5)
-af.display(a)
-b = af.Array(a)
-af.display(b)
-
-c = a.copy()
-af.display(c)
-af.display(a[0,0])
-af.display(a[0])
-af.display(a[:])
-af.display(a[:,:])
-af.display(a[0:3,])
-af.display(a[-2:-1,-1])
-af.display(a[0:5])
-af.display(a[0:5:2])
-
-idx = af.Array(host.array('i', [0, 3, 2]))
-af.display(idx)
-aa = a[idx]
-af.display(aa)
-
-a[0] = 1
-af.display(a)
-a[0] = af.randu(1, 5)
-af.display(a)
-a[:] = af.randu(5,5)
-af.display(a)
-a[:,-1] = af.randu(5,1)
-af.display(a)
-a[0:5:2] = af.randu(3, 5)
-af.display(a)
-a[idx, idx] = af.randu(3,3)
-af.display(a)
-
-
-a = af.randu(5,1)
-b = af.randu(5,1)
-af.display(a)
-af.display(b)
-for ii in ParallelRange(1,3):
- a[ii] = b[ii]
-
-af.display(a)
-
-for ii in ParallelRange(2,5):
- b[ii] = 2
-af.display(b)
-
-a = af.randu(3,2)
-rows = af.constant(0, 1, dtype=af.Dtype.s32)
-b = a[:,rows]
-af.display(b)
-for r in rows:
- af.display(r)
- af.display(b[:,r])
-
-a = af.randu(3)
-c = af.randu(3)
-b = af.constant(1,3,dtype=af.Dtype.b8)
-af.display(a)
-a[b] = c
-af.display(a)
diff --git a/tests/simple_lapack.py b/tests/simple_lapack.py
deleted file mode 100755
index b7dae1a..0000000
--- a/tests/simple_lapack.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/python
-#######################################################
-# Copyright (c) 2015, ArrayFire
-# All rights reserved.
-#
-# This file is distributed under 3-clause BSD license.
-# The complete license agreement can be obtained at:
-# http://arrayfire.com/licenses/BSD-3-Clause
-########################################################
-import arrayfire as af
-
-a = af.randu(5,5)
-
-l,u,p = af.lu(a)
-
-af.display(l)
-af.display(u)
-af.display(p)
-
-p = af.lu_inplace(a, "full")
-
-af.display(a)
-af.display(p)
-
-a = af.randu(5,3)
-
-q,r,t = af.qr(a)
-
-af.display(q)
-af.display(r)
-af.display(t)
-
-af.qr_inplace(a)
-
-af.display(a)
-
-a = af.randu(5, 5)
-a = af.matmulTN(a, a) + 10 * af.identity(5,5)
-
-R,info = af.cholesky(a)
-af.display(R)
-print(info)
-
-af.cholesky_inplace(a)
-af.display(a)
-
-a = af.randu(5,5)
-ai = af.inverse(a)
-
-af.display(a)
-af.display(ai)
-
-x0 = af.randu(5, 3)
-b = af.matmul(a, x0)
-x1 = af.solve(a, b)
-
-af.display(x0)
-af.display(x1)
-
-p = af.lu_inplace(a)
-
-x2 = af.solve_lu(a, p, b)
-
-af.display(x2)
-
-print(af.rank(a))
-print(af.det(a))
-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))
diff --git a/tests/simple_signal.py b/tests/simple_signal.py
deleted file mode 100755
index e8e3f22..0000000
--- a/tests/simple_signal.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/python
-#######################################################
-# Copyright (c) 2015, ArrayFire
-# All rights reserved.
-#
-# This file is distributed under 3-clause BSD license.
-# The complete license agreement can be obtained at:
-# http://arrayfire.com/licenses/BSD-3-Clause
-########################################################
-
-import arrayfire as af
-
-a = af.randu(10, 1)
-pos0 = af.randu(10) * 10
-af.display(af.approx1(a, pos0))
-
-a = af.randu(3, 3)
-pos0 = af.randu(3, 3) * 10
-pos1 = af.randu(3, 3) * 10
-
-af.display(af.approx2(a, pos0, pos1))
-
-a = af.randu(8, 1)
-af.display(a)
-
-af.display(af.fft(a))
-af.display(af.dft(a))
-af.display(af.real(af.ifft(af.fft(a))))
-af.display(af.real(af.idft(af.dft(a))))
-
-a = af.randu(4, 4)
-af.display(a)
-
-af.display(af.fft2(a))
-af.display(af.dft(a))
-af.display(af.real(af.ifft2(af.fft2(a))))
-af.display(af.real(af.idft(af.dft(a))))
-
-a = af.randu(4, 4, 2)
-af.display(a)
-
-af.display(af.fft3(a))
-af.display(af.dft(a))
-af.display(af.real(af.ifft3(af.fft3(a))))
-af.display(af.real(af.idft(af.dft(a))))
-
-a = af.randu(10, 1)
-b = af.randu(3, 1)
-af.display(af.convolve1(a, b))
-af.display(af.fft_convolve1(a, b))
-af.display(af.convolve(a, b))
-af.display(af.fft_convolve(a, b))
-
-a = af.randu(5, 5)
-b = af.randu(3, 3)
-af.display(af.convolve2(a, b))
-af.display(af.fft_convolve2(a, b))
-af.display(af.convolve(a, b))
-af.display(af.fft_convolve(a, b))
-
-a = af.randu(5, 5, 3)
-b = af.randu(3, 3, 2)
-af.display(af.convolve3(a, b))
-af.display(af.fft_convolve3(a, b))
-af.display(af.convolve(a, b))
-af.display(af.fft_convolve(a, b))
-
-
-b = af.randu(3, 1)
-x = af.randu(10, 1)
-a = af.randu(2, 1)
-af.display(af.fir(b, x))
-af.display(af.iir(b, a, x))
diff --git a/tests/simple_statistics.py b/tests/simple_statistics.py
deleted file mode 100755
index a57b018..0000000
--- a/tests/simple_statistics.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/python
-#######################################################
-# Copyright (c) 2015, ArrayFire
-# All rights reserved.
-#
-# This file is distributed under 3-clause BSD license.
-# The complete license agreement can be obtained at:
-# http://arrayfire.com/licenses/BSD-3-Clause
-########################################################
-
-import arrayfire as af
-
-a = af.randu(5, 5)
-b = af.randu(5, 5)
-w = af.randu(5, 1)
-
-af.display(af.mean(a, dim=0))
-af.display(af.mean(a, weights=w, dim=0))
-print(af.mean(a))
-print(af.mean(a, weights=w))
-
-af.display(af.var(a, dim=0))
-af.display(af.var(a, isbiased=True, dim=0))
-af.display(af.var(a, weights=w, dim=0))
-print(af.var(a))
-print(af.var(a, isbiased=True))
-print(af.var(a, weights=w))
-
-af.display(af.stdev(a, dim=0))
-print(af.stdev(a))
-
-af.display(af.var(a, dim=0))
-af.display(af.var(a, isbiased=True, dim=0))
-print(af.var(a))
-print(af.var(a, isbiased=True))
-
-af.display(af.median(a, dim=0))
-print(af.median(w))
-
-print(af.corrcoef(a, b))
diff --git a/tests/simple_blas.py b/tests/simple_tests.py
similarity index 56%
rename from tests/simple_blas.py
rename to tests/simple_tests.py
index 47cc4b6..67fb8c9 100755
--- a/tests/simple_blas.py
+++ b/tests/simple_tests.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+
#######################################################
# Copyright (c) 2015, ArrayFire
# All rights reserved.
@@ -8,14 +9,17 @@
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
-import arrayfire as af
+import simple
+import sys
+
+if __name__ == "__main__":
+ verbose = False
-a = af.randu(5,5)
-b = af.randu(5,5)
+ if len(sys.argv) > 1:
+ verbose = int(sys.argv[1]) != False
-af.display(af.matmul(a,b))
-af.display(af.matmul(a,b,af.MATPROP.TRANS))
-af.display(af.matmul(a,b,af.MATPROP.NONE, af.MATPROP.TRANS))
+ test_list = None
+ if len(sys.argv) > 2:
+ test_list = sys.argv[2:]
-b = af.randu(5,1)
-af.display(af.dot(b,b))
+ simple.tests.run(test_list, verbose)
--
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