[Numpy-svn] r3677 - trunk/numpy/doc/swig

numpy-svn@scip... numpy-svn@scip...
Fri Apr 6 14:45:09 CDT 2007


Author: wfspotz@sandia.gov
Date: 2007-04-06 14:45:03 -0500 (Fri, 06 Apr 2007)
New Revision: 3677

Modified:
   trunk/numpy/doc/swig/testMatrix.py
   trunk/numpy/doc/swig/testTensor.py
   trunk/numpy/doc/swig/testVector.py
Log:
Added 'bad list' tests to IN_ARRAY typemap tests

Modified: trunk/numpy/doc/swig/testMatrix.py
===================================================================
--- trunk/numpy/doc/swig/testMatrix.py	2007-04-06 19:13:15 UTC (rev 3676)
+++ trunk/numpy/doc/swig/testMatrix.py	2007-04-06 19:45:03 UTC (rev 3677)
@@ -36,6 +36,14 @@
         self.assertEquals(det(matrix), 30)
 
     # Test (type IN_ARRAY2[ANY][ANY]) typemap
+    def testDetBadList(self):
+        "Test det function with bad list"
+        print >>sys.stderr, self.typeStr, "... ",
+        det = Matrix.__dict__[self.typeStr + "Det"]
+        matrix = [[8,7], ["e", "pi"]]
+        self.assertRaises(BadListError, det, matrix)
+
+    # Test (type IN_ARRAY2[ANY][ANY]) typemap
     def testDetWrongDim(self):
         "Test det function with wrong dimensions"
         print >>sys.stderr, self.typeStr, "... ",
@@ -67,6 +75,14 @@
         self.assertEquals(max(matrix), 6)
 
     # Test (type* IN_ARRAY2, int DIM1, int DIM2) typemap
+    def testMaxBadList(self):
+        "Test max function with bad list"
+        print >>sys.stderr, self.typeStr, "... ",
+        max = Matrix.__dict__[self.typeStr + "Max"]
+        matrix = [[6,"five",4], ["three", 2, "one"]]
+        self.assertRaises(BadListError, max, matrix)
+
+    # Test (type* IN_ARRAY2, int DIM1, int DIM2) typemap
     def testMaxNonContainer(self):
         "Test max function with non-container"
         print >>sys.stderr, self.typeStr, "... ",
@@ -89,6 +105,14 @@
         self.assertEquals(min(matrix), 4)
 
     # Test (int DIM1, int DIM2, type* IN_ARRAY2) typemap
+    def testMinBadList(self):
+        "Test min function with bad list"
+        print >>sys.stderr, self.typeStr, "... ",
+        min = Matrix.__dict__[self.typeStr + "Min"]
+        matrix = [["nine","eight"], ["seven","six"]]
+        self.assertRaises(BadListError, min, matrix)
+
+    # Test (int DIM1, int DIM2, type* IN_ARRAY2) typemap
     def testMinWrongDim(self):
         "Test min function with wrong dimensions"
         print >>sys.stderr, self.typeStr, "... ",

Modified: trunk/numpy/doc/swig/testTensor.py
===================================================================
--- trunk/numpy/doc/swig/testTensor.py	2007-04-06 19:13:15 UTC (rev 3676)
+++ trunk/numpy/doc/swig/testTensor.py	2007-04-06 19:45:03 UTC (rev 3677)
@@ -42,6 +42,15 @@
             self.assertAlmostEqual(norm(tensor), self.result, 6)
 
     # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
+    def testNormBadList(self):
+        "Test norm function with bad list"
+        print >>sys.stderr, self.typeStr, "... ",
+        norm = Tensor.__dict__[self.typeStr + "Norm"]
+        tensor = [[[0,"one"],[2,3]],
+                  [[3,"two"],[1,0]]]
+        self.assertRaises(BadListError, norm, tensor)
+
+    # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
     def testNormWrongDim(self):
         "Test norm function with wrong dimensions"
         print >>sys.stderr, self.typeStr, "... ",
@@ -76,6 +85,15 @@
         self.assertEquals(max(tensor), 8)
 
     # Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
+    def testMaxBadList(self):
+        "Test max function with bad list"
+        print >>sys.stderr, self.typeStr, "... ",
+        max = Tensor.__dict__[self.typeStr + "Max"]
+        tensor = [[[1,"two"], [3,4]],
+                  [[5,"six"], [7,8]]]
+        self.assertRaises(BadListError, max, tensor)
+
+    # Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
     def testMaxNonContainer(self):
         "Test max function with non-container"
         print >>sys.stderr, self.typeStr, "... ",
@@ -99,8 +117,17 @@
         self.assertEquals(min(tensor), 2)
 
     # Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap
+    def testMinBadList(self):
+        "Test min function with bad list"
+        print >>sys.stderr, self.typeStr, "... ",
+        min = Tensor.__dict__[self.typeStr + "Min"]
+        tensor = [[["nine",8], [7,6]],
+                  [["five",4], [3,2]]]
+        self.assertRaises(BadListError, min, tensor)
+
+    # Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap
     def testMinNonContainer(self):
-        "Test min function"
+        "Test min function with non-container"
         print >>sys.stderr, self.typeStr, "... ",
         min = Tensor.__dict__[self.typeStr + "Min"]
         self.assertRaises(TypeError, min, True)

Modified: trunk/numpy/doc/swig/testVector.py
===================================================================
--- trunk/numpy/doc/swig/testVector.py	2007-04-06 19:13:15 UTC (rev 3676)
+++ trunk/numpy/doc/swig/testVector.py	2007-04-06 19:45:03 UTC (rev 3677)
@@ -35,6 +35,13 @@
         self.assertEquals(length([5, 12, 0]), 13)
 
     # Test the (type IN_ARRAY1[ANY]) typemap
+    def testLengthBadList(self):
+        "Test length function with bad list"
+        print >>sys.stderr, self.typeStr, "... ",
+        length = Vector.__dict__[self.typeStr + "Length"]
+        self.assertRaises(BadListError, length, [5, "twelve", 0])
+
+    # Test the (type IN_ARRAY1[ANY]) typemap
     def testLengthWrongSize(self):
         "Test length function with wrong size"
         print >>sys.stderr, self.typeStr, "... ",
@@ -63,6 +70,13 @@
         self.assertEquals(prod([1,2,3,4]), 24)
 
     # Test the (type* IN_ARRAY1, int DIM1) typemap
+    def testProdBadList(self):
+        "Test prod function with bad list"
+        print >>sys.stderr, self.typeStr, "... ",
+        prod = Vector.__dict__[self.typeStr + "Prod"]
+        self.assertRaises(BadListError, prod, [[1,"two"], ["e","pi"]])
+
+    # Test the (type* IN_ARRAY1, int DIM1) typemap
     def testProdWrongDim(self):
         "Test prod function with wrong dimensions"
         print >>sys.stderr, self.typeStr, "... ",
@@ -84,6 +98,13 @@
         self.assertEquals(sum([5,6,7,8]), 26)
 
     # Test the (int DIM1, type* IN_ARRAY1) typemap
+    def testSumBadList(self):
+        "Test sum function with bad list"
+        print >>sys.stderr, self.typeStr, "... ",
+        sum = Vector.__dict__[self.typeStr + "Sum"]
+        self.assertRaises(BadListError, sum, [3,4, 5, "pi"])
+
+    # Test the (int DIM1, type* IN_ARRAY1) typemap
     def testSumWrongDim(self):
         "Test sum function with wrong dimensions"
         print >>sys.stderr, self.typeStr, "... ",



More information about the Numpy-svn mailing list