[arrayfire] 24/84: Fixing select and replace tests
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Jan 4 23:22:18 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository arrayfire.
commit 52a8409cb510083e242cf5280bdc63a173ff7902
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date: Mon Dec 14 11:18:17 2015 -0500
Fixing select and replace tests
---
test/replace.cpp | 22 +++++++++++++++++-----
test/select.cpp | 20 +++++++++++++++-----
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/test/replace.cpp b/test/replace.cpp
index c6d3b5d..9e99eae 100644
--- a/test/replace.cpp
+++ b/test/replace.cpp
@@ -35,10 +35,17 @@ void replaceTest(const dim4 &dims)
af::dtype ty = (af::dtype)af::dtype_traits<T>::af_type;
array a = randu(dims, ty);
- array c = a.copy();
- array cond = randu(dims, ty) > constant(0.3, dims, ty);
array b = randu(dims, ty);
+ if (a.isinteger()) {
+ a = (a % (1 << 30)).as(ty);
+ b = (b % (1 << 30)).as(ty);
+ }
+
+ array c = a.copy();
+
+ array cond = randu(dims, ty) > a;
+
replace(c, cond, b);
int num = (int)a.elements();
@@ -65,8 +72,13 @@ void replaceScalarTest(const dim4 &dims)
af::dtype ty = (af::dtype)af::dtype_traits<T>::af_type;
array a = randu(dims, ty);
+
+ if (a.isinteger()) {
+ a = (a % (1 << 30)).as(ty);
+ }
+
array c = a.copy();
- array cond = randu(dims, ty) > constant(0.3, dims, ty);
+ array cond = randu(dims, ty) > a;
double b = 3;
replace(c, cond, b);
@@ -81,7 +93,7 @@ void replaceScalarTest(const dim4 &dims)
cond.host(&hcond[0]);
for (int i = 0; i < num; i++) {
- ASSERT_EQ(hc[i], hcond[i] ? b : ha[i]);
+ ASSERT_EQ(hc[i], hcond[i] ? T(b) : ha[i]);
}
}
@@ -103,7 +115,7 @@ TEST(Replace, NaN)
array a = randu(dims, ty);
a(seq(a.dims(0) / 2), span, span, span) = af::NaN;
array c = a.copy();
- double b = 0;
+ float b = 0;
replace(c, isNaN(c), b);
int num = (int)a.elements();
diff --git a/test/select.cpp b/test/select.cpp
index 91c8110..1c39282 100644
--- a/test/select.cpp
+++ b/test/select.cpp
@@ -34,9 +34,15 @@ void selectTest(const dim4 &dims)
af::dtype ty = (af::dtype)af::dtype_traits<T>::af_type;
array a = randu(dims, ty);
- array cond = randu(dims, ty) > constant(0.3, dims, ty);
array b = randu(dims, ty);
+ if (a.isinteger()) {
+ a = (a % (1 << 30)).as(ty);
+ b = (b % (1 << 30)).as(ty);
+ }
+
+ array cond = randu(dims, ty) > a;
+
array c = select(cond, a, b);
int num = (int)a.elements();
@@ -63,9 +69,13 @@ void selectScalarTest(const dim4 &dims)
af::dtype ty = (af::dtype)af::dtype_traits<T>::af_type;
array a = randu(dims, ty);
- array cond = randu(dims, ty) > constant(0.3, dims, ty);
+ array cond = randu(dims, ty) > a;
double b = 3;
+ if (a.isinteger()) {
+ a = (a % (1 << 30)).as(ty);
+ }
+
array c = is_right ? select(cond, a, b) : select(cond, b, a);
int num = (int)a.elements();
@@ -80,11 +90,11 @@ void selectScalarTest(const dim4 &dims)
if (is_right) {
for (int i = 0; i < num; i++) {
- ASSERT_EQ(hc[i], hcond[i] ? ha[i] : b);
+ ASSERT_EQ(hc[i], hcond[i] ? ha[i] : T(b));
}
} else {
for (int i = 0; i < num; i++) {
- ASSERT_EQ(hc[i], hcond[i] ? b : ha[i]);
+ ASSERT_EQ(hc[i], hcond[i] ? T(b) : ha[i]);
}
}
}
@@ -111,7 +121,7 @@ TEST(Select, NaN)
array a = randu(dims, ty);
a(seq(a.dims(0) / 2), span, span, span) = af::NaN;
- double b = 0;
+ float b = 0;
array c = select(isNaN(a), b, a);
int num = (int)a.elements();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git
More information about the debian-science-commits
mailing list