[python-arrayfire] 46/58: Fixing bugs in random and random tests
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Sep 28 13:57:08 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository python-arrayfire.
commit 85465c2fae89da37f4d6f0452383b18ab08f6390
Author: Pavan Yalamanchili <contact at pavanky.com>
Date: Fri Sep 23 17:36:35 2016 -0700
Fixing bugs in random and random tests
---
arrayfire/__init__.py | 1 +
arrayfire/random.py | 20 ++++++++++----------
arrayfire/tests/simple/__init__.py | 1 +
arrayfire/tests/simple/random.py | 2 +-
4 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/arrayfire/__init__.py b/arrayfire/__init__.py
index 74d1dca..c392d24 100644
--- a/arrayfire/__init__.py
+++ b/arrayfire/__init__.py
@@ -72,6 +72,7 @@ from .bcast import *
from .index import *
from .interop import *
from .timer import *
+from .random import *
# do not export default modules as part of arrayfire
del ct
diff --git a/arrayfire/random.py b/arrayfire/random.py
index 60148a8..d95fa90 100644
--- a/arrayfire/random.py
+++ b/arrayfire/random.py
@@ -81,7 +81,7 @@ class Random_Engine(object):
safe_call(backend.get().af_random_engine_get_seed(ct.pointer(seed), self.engine))
return seed.value
-def randu(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32, random_engine=None):
+def randu(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32, engine=None):
"""
Create a multi dimensional array containing values from a uniform distribution.
@@ -102,8 +102,8 @@ def randu(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32, random_engine=None):
dtype : optional: af.Dtype. default: af.Dtype.f32.
Data type of the array.
- random_engine : optional: Random_Engine. default: None.
- If random_engine is None, uses a default engine created by arrayfire.
+ engine : optional: Random_Engine. default: None.
+ If engine is None, uses a default engine created by arrayfire.
Returns
-------
@@ -118,14 +118,14 @@ def randu(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32, random_engine=None):
out = Array()
dims = dim4(d0, d1, d2, d3)
- if random_engine is None:
+ if engine is None:
safe_call(backend.get().af_randu(ct.pointer(out.arr), 4, ct.pointer(dims), dtype.value))
else:
- safe_call(backend.get().af_random_uniform(ct.pointer(out.arr), 4, ct.pointer(dims), random_engine.engine))
+ safe_call(backend.get().af_random_uniform(ct.pointer(out.arr), 4, ct.pointer(dims), dtype.value, engine.engine))
return out
-def randn(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32, random_engine=None):
+def randn(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32, engine=None):
"""
Create a multi dimensional array containing values from a normal distribution.
@@ -146,8 +146,8 @@ def randn(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32, random_engine=None):
dtype : optional: af.Dtype. default: af.Dtype.f32.
Data type of the array.
- random_engine : optional: Random_Engine. default: None.
- If random_engine is None, uses a default engine created by arrayfire.
+ engine : optional: Random_Engine. default: None.
+ If engine is None, uses a default engine created by arrayfire.
Returns
-------
@@ -163,10 +163,10 @@ def randn(d0, d1=None, d2=None, d3=None, dtype=Dtype.f32, random_engine=None):
out = Array()
dims = dim4(d0, d1, d2, d3)
- if random_engine is None:
+ if engine is None:
safe_call(backend.get().af_randn(ct.pointer(out.arr), 4, ct.pointer(dims), dtype.value))
else:
- safe_call(backend.get().af_random_normal(ct.pointer(out.arr), 4, ct.pointer(dims), random_engine.engine))
+ safe_call(backend.get().af_random_normal(ct.pointer(out.arr), 4, ct.pointer(dims), dtype.value, engine.engine))
return out
diff --git a/arrayfire/tests/simple/__init__.py b/arrayfire/tests/simple/__init__.py
index 4651972..0a1588e 100644
--- a/arrayfire/tests/simple/__init__.py
+++ b/arrayfire/tests/simple/__init__.py
@@ -18,4 +18,5 @@ from .index import *
from .lapack import *
from .signal import *
from .statistics import *
+from .random import *
from ._util import tests
diff --git a/arrayfire/tests/simple/random.py b/arrayfire/tests/simple/random.py
index 6b72a91..5443898 100644
--- a/arrayfire/tests/simple/random.py
+++ b/arrayfire/tests/simple/random.py
@@ -25,7 +25,7 @@ def simple_random(verbose=False):
af.set_seed(1024)
assert(af.get_seed() == 1024)
- engine = Random_Engine(RANDOM_ENGINE.MERSENNE_GP11213, 100)
+ engine = af.Random_Engine(af.RANDOM_ENGINE.MERSENNE_GP11213, 100)
display_func(af.randu(3, 3, 1, 2, engine=engine))
display_func(af.randu(3, 3, 1, 2, af.Dtype.s32, engine=engine))
--
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