[arrayfire] 256/284: TEST: Adding tests for 3D and 4D select and replace

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:39 UTC 2016


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

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

commit f228de3243492817f4909991ec8c96457d42c6aa
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Thu Jan 28 17:18:16 2016 -0500

    TEST: Adding tests for 3D and 4D select and replace
---
 test/replace.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++
 test/select.cpp  | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)

diff --git a/test/replace.cpp b/test/replace.cpp
index 9e99eae..faa5636 100644
--- a/test/replace.cpp
+++ b/test/replace.cpp
@@ -130,3 +130,46 @@ TEST(Replace, NaN)
         ASSERT_EQ(hc[i], std::isnan(ha[i]) ? b : ha[i]);
     }
 }
+
+TEST(Replace, ISSUE_1249)
+{
+    dim4 dims(2, 3, 4);
+    array cond = af::randu(dims) > 0.5;
+    array a = af::randu(dims);
+    array b = a.copy();
+    replace(b, !cond, a - a * 0.9);
+    array c = a - a * cond * 0.9;
+
+    int num = (int)dims.elements();
+    std::vector<float> hb(num);
+    std::vector<float> hc(num);
+
+    b.host(&hb[0]);
+    c.host(&hc[0]);
+
+    for (int i = 0; i < num; i++) {
+        ASSERT_EQ(hc[i], hb[i]) << "at " << i;
+    }
+}
+
+
+TEST(Replace, 4D)
+{
+    dim4 dims(2, 3, 4, 2);
+    array cond = af::randu(dims) > 0.5;
+    array a = af::randu(dims);
+    array b = a.copy();
+    replace(b, !cond, a - a * 0.9);
+    array c = a - a * cond * 0.9;
+
+    int num = (int)dims.elements();
+    std::vector<float> hb(num);
+    std::vector<float> hc(num);
+
+    b.host(&hb[0]);
+    c.host(&hc[0]);
+
+    for (int i = 0; i < num; i++) {
+        ASSERT_EQ(hc[i], hb[i]) << "at " << i;
+    }
+}
diff --git a/test/select.cpp b/test/select.cpp
index 1c39282..6e772ac 100644
--- a/test/select.cpp
+++ b/test/select.cpp
@@ -136,3 +136,43 @@ TEST(Select, NaN)
         ASSERT_EQ(hc[i], std::isnan(ha[i]) ? b : ha[i]);
     }
 }
+
+TEST(Select, ISSUE_1249)
+{
+    dim4 dims(2, 3, 4);
+    array cond = af::randu(dims) > 0.5;
+    array a = af::randu(dims);
+    array b = select(cond, a - a * 0.9, a);
+    array c = a - a * cond * 0.9;
+
+    int num = (int)dims.elements();
+    std::vector<float> hb(num);
+    std::vector<float> hc(num);
+
+    b.host(&hb[0]);
+    c.host(&hc[0]);
+
+    for (int i = 0; i < num; i++) {
+        ASSERT_EQ(hc[i], hb[i]) << "at " << i;
+    }
+}
+
+TEST(Select, 4D)
+{
+    dim4 dims(2, 3, 4, 2);
+    array cond = af::randu(dims) > 0.5;
+    array a = af::randu(dims);
+    array b = select(cond, a - a * 0.9, a);
+    array c = a - a * cond * 0.9;
+
+    int num = (int)dims.elements();
+    std::vector<float> hb(num);
+    std::vector<float> hc(num);
+
+    b.host(&hb[0]);
+    c.host(&hc[0]);
+
+    for (int i = 0; i < num; i++) {
+        ASSERT_EQ(hc[i], hb[i]) << "at " << i;
+    }
+}

-- 
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