summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorwfspotz@sandia.gov <wfspotz@sandia.gov@localhost>2007-04-06 19:45:03 +0000
committerwfspotz@sandia.gov <wfspotz@sandia.gov@localhost>2007-04-06 19:45:03 +0000
commit9d14fc91d8d12395719a257917c363cf91400962 (patch)
tree6eab2a9fd3b479f8d9b852a804c0169cc73557be /numpy
parent4b9f5d9cbf52406eaebf28e7df4fd04e1024e708 (diff)
downloadnumpy-9d14fc91d8d12395719a257917c363cf91400962.tar.gz
Added 'bad list' tests to IN_ARRAY typemap tests
Diffstat (limited to 'numpy')
-rwxr-xr-xnumpy/doc/swig/testMatrix.py24
-rwxr-xr-xnumpy/doc/swig/testTensor.py29
-rwxr-xr-xnumpy/doc/swig/testVector.py21
3 files changed, 73 insertions, 1 deletions
diff --git a/numpy/doc/swig/testMatrix.py b/numpy/doc/swig/testMatrix.py
index cce16b792..933423fe9 100755
--- a/numpy/doc/swig/testMatrix.py
+++ b/numpy/doc/swig/testMatrix.py
@@ -36,6 +36,14 @@ class MatrixTestCase(unittest.TestCase):
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 @@ class MatrixTestCase(unittest.TestCase):
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 @@ class MatrixTestCase(unittest.TestCase):
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, "... ",
diff --git a/numpy/doc/swig/testTensor.py b/numpy/doc/swig/testTensor.py
index 87beba62a..f68e6b720 100755
--- a/numpy/doc/swig/testTensor.py
+++ b/numpy/doc/swig/testTensor.py
@@ -42,6 +42,15 @@ class TensorTestCase(unittest.TestCase):
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 @@ class TensorTestCase(unittest.TestCase):
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 @@ class TensorTestCase(unittest.TestCase):
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)
diff --git a/numpy/doc/swig/testVector.py b/numpy/doc/swig/testVector.py
index 1e8729670..82a922e25 100755
--- a/numpy/doc/swig/testVector.py
+++ b/numpy/doc/swig/testVector.py
@@ -35,6 +35,13 @@ class VectorTestCase(unittest.TestCase):
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 @@ class VectorTestCase(unittest.TestCase):
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 @@ class VectorTestCase(unittest.TestCase):
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, "... ",