From 773177d2b0029889beb2d7490cfeebd3b1799115 Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Wed, 20 May 2015 09:51:06 -0400 Subject: [PATCH] * Added tester for array functions. --- TESTS/test_array.py | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 TESTS/test_array.py diff --git a/TESTS/test_array.py b/TESTS/test_array.py new file mode 100644 index 0000000..eeea85f --- /dev/null +++ b/TESTS/test_array.py @@ -0,0 +1,55 @@ + +import numpy + + +def test_array_hstack1(): + # 20150520 + from numpy import array + from wpylib.array_tools import array_hstack + + print("test_array_hstack1::") + + A1 = array([[1.5, 2.3, 1.7], + [3.5, 1.0, 9.7], + [4.5, 3.0, 0.5], + [5.0, 8.1, 2.4]]) + A2 = array([12.1, 21.5, 47.1, 32.1]) + A3 = array([1.1, 2.5, 7.7, 6.6]) + A123 = array_hstack((A1, A2, A3)) + + A123_refs = array([[ 1.5, 2.3, 1.7, 12.1, 1.1], + [ 3.5, 1. , 9.7, 21.5, 2.5], + [ 4.5, 3. , 0.5, 47.1, 7.7], + [ 5. , 8.1, 2.4, 32.1, 6.6]]) + print(A123) + assert numpy.all(A123 == A123_refs) + + +def test_array_vstack1(): + # 20150520 + from numpy import array + from wpylib.array_tools import array_vstack + + print("test_array_vstack1::") + + A1 = array([[1.5, 2.3, 1.7], + [3.5, 1.0, 9.7], + [4.5, 3.0, 0.5], + [5.0, 8.1, 2.4]]) + A2 = array([12.1, 21.5, 47.1]) + A3 = array([1.1, 2.5, 7.7]) + A123 = array_vstack((A1, A2, A3)) + + A123_refs = array([[ 1.5, 2.3, 1.7], + [ 3.5, 1. , 9.7], + [ 4.5, 3. , 0.5], + [ 5. , 8.1, 2.4], + [ 12.1, 21.5, 47.1], + [ 1.1, 2.5, 7.7]]) + + print(A123) + assert numpy.all(A123 == A123_refs) + + +if __name__ == '__main__': + test_array_vstack1()