diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-08-18 11:51:25 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-08-18 11:51:25 -0600 |
commit | fbd6510d58a47ea0d166c48a82793f05425406e4 (patch) | |
tree | 330ce703eb02d20f96099c3fe0fc36ae33d4905b /doc | |
parent | 8ddb0ce0acafe75d78df528b4d2540dfbf4b364d (diff) | |
download | numpy-fbd6510d58a47ea0d166c48a82793f05425406e4.tar.gz |
STY: Giant comma spacing fixup.
Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long
and will need to be broken at some point. OTOH, some lines were already
too long and need to be broken at some point. Now seems as good a time
as any to do this with open PRs at a minimum.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/newdtype_example/example.py | 2 | ||||
-rw-r--r-- | doc/newdtype_example/setup.py | 2 | ||||
-rw-r--r-- | doc/numpybook/comparison/ctypes/interface.py | 2 | ||||
-rw-r--r-- | doc/numpybook/comparison/timing.py | 6 | ||||
-rw-r--r-- | doc/numpybook/comparison/weave/filter.py | 2 | ||||
-rw-r--r-- | doc/numpybook/comparison/weave/inline.py | 10 | ||||
-rw-r--r-- | doc/numpybook/runcode.py | 4 | ||||
-rwxr-xr-x | doc/swig/test/setup.py | 2 | ||||
-rwxr-xr-x | doc/swig/test/testArray.py | 4 | ||||
-rwxr-xr-x | doc/swig/test/testFarray.py | 16 | ||||
-rw-r--r-- | doc/swig/test/testFortran.py | 2 | ||||
-rwxr-xr-x | doc/swig/test/testMatrix.py | 62 | ||||
-rw-r--r-- | doc/swig/test/testSuperTensor.py | 60 | ||||
-rwxr-xr-x | doc/swig/test/testTensor.py | 112 | ||||
-rwxr-xr-x | doc/swig/test/testVector.py | 56 |
15 files changed, 171 insertions, 171 deletions
diff --git a/doc/newdtype_example/example.py b/doc/newdtype_example/example.py index 6e9bf4334..6be9caa75 100644 --- a/doc/newdtype_example/example.py +++ b/doc/newdtype_example/example.py @@ -8,7 +8,7 @@ import numpy as np # So, the setitem code will be called with scalars on the # wrong shaped array. # But we can get a view as an ndarray of the given type: -g = np.array([1,2,3,4,5,6,7,8]).view(ff.floatint_type) +g = np.array([1, 2, 3, 4, 5, 6, 7, 8]).view(ff.floatint_type) # Now, the elements will be the scalar type associated # with the ndarray. diff --git a/doc/newdtype_example/setup.py b/doc/newdtype_example/setup.py index 494343b28..2222f0de1 100644 --- a/doc/newdtype_example/setup.py +++ b/doc/newdtype_example/setup.py @@ -4,7 +4,7 @@ from numpy.distutils.core import setup def configuration(parent_package = '', top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('floatint',parent_package,top_path) + config = Configuration('floatint', parent_package, top_path) config.add_extension('floatint', sources = ['floatint.c']); diff --git a/doc/numpybook/comparison/ctypes/interface.py b/doc/numpybook/comparison/ctypes/interface.py index 34e34ca71..1fabe3170 100644 --- a/doc/numpybook/comparison/ctypes/interface.py +++ b/doc/numpybook/comparison/ctypes/interface.py @@ -49,7 +49,7 @@ def add(a, b): a = N.require(a, dtype, requires) b = N.require(b, dtype, requires) c = N.empty_like(a) - func(a,b,c,a.size) + func(a, b, c, a.size) return c def filter2d(a): diff --git a/doc/numpybook/comparison/timing.py b/doc/numpybook/comparison/timing.py index 0d47c7eba..1c70b48ac 100644 --- a/doc/numpybook/comparison/timing.py +++ b/doc/numpybook/comparison/timing.py @@ -43,7 +43,7 @@ b = N.zeros_like(a) filter.DFILTER2D(a,b) """ -N = [10,20,30,40,50,100,200,300, 400, 500] +N = [10, 20, 30, 40, 50, 100, 200, 300, 400, 500] res = {} @@ -57,6 +57,6 @@ for kind in ['f2py']:#['ctypes', 'pyrex', 'weave', 'f2py']: print(sys.path) for n in N: print("%s - %d" % (kind, n)) - t = timeit.Timer(eval('%s_run'%kind), eval('%s_pre %% (%d,%d)'%(kind,n,n))) - mytime = min(t.repeat(3,100)) + t = timeit.Timer(eval('%s_run'%kind), eval('%s_pre %% (%d,%d)'%(kind, n, n))) + mytime = min(t.repeat(3, 100)) res[kind].append(mytime) diff --git a/doc/numpybook/comparison/weave/filter.py b/doc/numpybook/comparison/weave/filter.py index bbdc9ea85..309764c29 100644 --- a/doc/numpybook/comparison/weave/filter.py +++ b/doc/numpybook/comparison/weave/filter.py @@ -20,5 +20,5 @@ def filter(a): } """ b = zeros_like(a) - weave.inline(code,['a','b']) + weave.inline(code, ['a', 'b']) return b diff --git a/doc/numpybook/comparison/weave/inline.py b/doc/numpybook/comparison/weave/inline.py index 3906553ed..6e98e6997 100644 --- a/doc/numpybook/comparison/weave/inline.py +++ b/doc/numpybook/comparison/weave/inline.py @@ -16,7 +16,7 @@ def example1(a): results[1] = 4.0; return_val = results; """ - return weave.inline(code,['a']) + return weave.inline(code, ['a']) def arr(a): if a.ndim != 2: @@ -36,16 +36,16 @@ def arr(a): } """ b = zeros_like(a) - weave.inline(code,['a','b']) + weave.inline(code, ['a', 'b']) return b a = [None]*10 print(example1(a)) print(a) -a = rand(512,512) +a = rand(512, 512) b = arr(a) -h = [[0.25,0.5,0.25],[0.5,1,0.5],[0.25,0.5,0.25]] +h = [[0.25, 0.5, 0.25], [0.5, 1, 0.5], [0.25, 0.5, 0.25]] import scipy.signal as ss -b2 = ss.convolve(h,a,'same') +b2 = ss.convolve(h, a, 'same') diff --git a/doc/numpybook/runcode.py b/doc/numpybook/runcode.py index 456846cad..c8c532728 100644 --- a/doc/numpybook/runcode.py +++ b/doc/numpybook/runcode.py @@ -131,7 +131,7 @@ def runpycode(lyxstr, name='MyCode'): def main(args): usage = "%prog {options} filename" parser = optparse.OptionParser(usage) - parser.add_option('-n','--name', default='MyCode') + parser.add_option('-n', '--name', default='MyCode') options, args = parser.parse_args(args) if len(args) < 1: @@ -143,7 +143,7 @@ def main(args): fid.close() print("Processing %s" % options.name) newstr = runpycode(str, options.name) - fid = file(args[0],'w') + fid = file(args[0], 'w') fid.write(newstr) fid.close() diff --git a/doc/swig/test/setup.py b/doc/swig/test/setup.py index c54b42ed4..e39114f91 100755 --- a/doc/swig/test/setup.py +++ b/doc/swig/test/setup.py @@ -59,6 +59,6 @@ setup(name = "NumpyTypemapTests", author = "Bill Spotz", py_modules = ["Array", "Farray", "Vector", "Matrix", "Tensor", "Fortran"], - ext_modules = [_Array , _Farray , _Vector , _Matrix , _Tensor, + ext_modules = [_Array, _Farray, _Vector, _Matrix, _Tensor, _Fortran] ) diff --git a/doc/swig/test/testArray.py b/doc/swig/test/testArray.py index 278a75f7a..d986de3b3 100755 --- a/doc/swig/test/testArray.py +++ b/doc/swig/test/testArray.py @@ -115,7 +115,7 @@ class Array1TestCase(unittest.TestCase): a = self.array1.view() self.failUnless(isinstance(a, np.ndarray)) self.failUnless(len(a) == self.length) - self.failUnless((a == [1,2,3,4,5]).all()) + self.failUnless((a == [1, 2, 3, 4, 5]).all()) ###################################################################### @@ -138,7 +138,7 @@ class Array2TestCase(unittest.TestCase): def testConstructor2(self): "Test Array2 array constructor" - na = np.zeros((3,4), dtype="l") + na = np.zeros((3, 4), dtype="l") aa = Array.Array2(na) self.failUnless(isinstance(aa, Array.Array2)) diff --git a/doc/swig/test/testFarray.py b/doc/swig/test/testFarray.py index 3905e26bd..15683b70b 100755 --- a/doc/swig/test/testFarray.py +++ b/doc/swig/test/testFarray.py @@ -16,7 +16,7 @@ else: BadListError = ValueError # Add the distutils-generated build directory to the python search path and then # import the extension module libDir = "lib.%s-%s" % (get_platform(), sys.version[:3]) -sys.path.insert(0,os.path.join("build", libDir)) +sys.path.insert(0, os.path.join("build", libDir)) import Farray ###################################################################### @@ -36,7 +36,7 @@ class FarrayTestCase(unittest.TestCase): "Test Farray copy constructor" for i in range(self.nrows): for j in range(self.ncols): - self.array[i,j] = i + j + self.array[i, j] = i + j arrayCopy = Farray.Farray(self.array) self.failUnless(arrayCopy == self.array) @@ -66,10 +66,10 @@ class FarrayTestCase(unittest.TestCase): n = self.ncols for i in range(m): for j in range(n): - self.array[i,j] = i*j + self.array[i, j] = i*j for i in range(m): for j in range(n): - self.failUnless(self.array[i,j] == i*j) + self.failUnless(self.array[i, j] == i*j) def testSetBad1(self): "Test Farray __setitem__ method, negative row" @@ -114,7 +114,7 @@ class FarrayTestCase(unittest.TestCase): """ for i in range(self.nrows): for j in range(self.ncols): - self.array[i,j] = i+j + self.array[i, j] = i+j self.failUnless(self.array.asString() == result) def testStr(self): @@ -128,20 +128,20 @@ class FarrayTestCase(unittest.TestCase): """ for i in range(self.nrows): for j in range(self.ncols): - self.array[i,j] = i-j + self.array[i, j] = i-j self.failUnless(str(self.array) == result) def testView(self): "Test Farray view method" for i in range(self.nrows): for j in range(self.ncols): - self.array[i,j] = i+j + self.array[i, j] = i+j a = self.array.view() self.failUnless(isinstance(a, np.ndarray)) self.failUnless(a.flags.f_contiguous) for i in range(self.nrows): for j in range(self.ncols): - self.failUnless(a[i,j] == i+j) + self.failUnless(a[i, j] == i+j) ###################################################################### diff --git a/doc/swig/test/testFortran.py b/doc/swig/test/testFortran.py index 2175ad1bf..a42af950e 100644 --- a/doc/swig/test/testFortran.py +++ b/doc/swig/test/testFortran.py @@ -47,7 +47,7 @@ class FortranTestCase(unittest.TestCase): "Test Fortran matrix initialized from nested list fortranarray" print(self.typeStr, "... ", end=' ', file=sys.stderr) second = Fortran.__dict__[self.typeStr + "SecondElement"] - matrix = np.asfortranarray([[0,1,2],[3,4,5],[6,7,8]], self.typeCode) + matrix = np.asfortranarray([[0, 1, 2], [3, 4, 5], [6, 7, 8]], self.typeCode) self.assertEquals(second(matrix), 3) ###################################################################### diff --git a/doc/swig/test/testMatrix.py b/doc/swig/test/testMatrix.py index d1721941e..af234e0e9 100755 --- a/doc/swig/test/testMatrix.py +++ b/doc/swig/test/testMatrix.py @@ -29,7 +29,7 @@ class MatrixTestCase(unittest.TestCase): "Test det function" print(self.typeStr, "... ", end=' ', file=sys.stderr) det = Matrix.__dict__[self.typeStr + "Det"] - matrix = [[8,7],[6,9]] + matrix = [[8, 7], [6, 9]] self.assertEquals(det(matrix), 30) # Test (type IN_ARRAY2[ANY][ANY]) typemap @@ -37,7 +37,7 @@ class MatrixTestCase(unittest.TestCase): "Test det function with bad list" print(self.typeStr, "... ", end=' ', file=sys.stderr) det = Matrix.__dict__[self.typeStr + "Det"] - matrix = [[8,7], ["e", "pi"]] + matrix = [[8, 7], ["e", "pi"]] self.assertRaises(BadListError, det, matrix) # Test (type IN_ARRAY2[ANY][ANY]) typemap @@ -45,7 +45,7 @@ class MatrixTestCase(unittest.TestCase): "Test det function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) det = Matrix.__dict__[self.typeStr + "Det"] - matrix = [8,7] + matrix = [8, 7] self.assertRaises(TypeError, det, matrix) # Test (type IN_ARRAY2[ANY][ANY]) typemap @@ -53,7 +53,7 @@ class MatrixTestCase(unittest.TestCase): "Test det function with wrong size" print(self.typeStr, "... ", end=' ', file=sys.stderr) det = Matrix.__dict__[self.typeStr + "Det"] - matrix = [[8,7,6], [5,4,3], [2,1,0]] + matrix = [[8, 7, 6], [5, 4, 3], [2, 1, 0]] self.assertRaises(TypeError, det, matrix) # Test (type IN_ARRAY2[ANY][ANY]) typemap @@ -68,7 +68,7 @@ class MatrixTestCase(unittest.TestCase): "Test max function" print(self.typeStr, "... ", end=' ', file=sys.stderr) max = Matrix.__dict__[self.typeStr + "Max"] - matrix = [[6,5,4],[3,2,1]] + matrix = [[6, 5, 4], [3, 2, 1]] self.assertEquals(max(matrix), 6) # Test (type* IN_ARRAY2, int DIM1, int DIM2) typemap @@ -76,7 +76,7 @@ class MatrixTestCase(unittest.TestCase): "Test max function with bad list" print(self.typeStr, "... ", end=' ', file=sys.stderr) max = Matrix.__dict__[self.typeStr + "Max"] - matrix = [[6,"five",4], ["three", 2, "one"]] + matrix = [[6, "five", 4], ["three", 2, "one"]] self.assertRaises(BadListError, max, matrix) # Test (type* IN_ARRAY2, int DIM1, int DIM2) typemap @@ -98,7 +98,7 @@ class MatrixTestCase(unittest.TestCase): "Test min function" print(self.typeStr, "... ", end=' ', file=sys.stderr) min = Matrix.__dict__[self.typeStr + "Min"] - matrix = [[9,8],[7,6],[5,4]] + matrix = [[9, 8], [7, 6], [5, 4]] self.assertEquals(min(matrix), 4) # Test (int DIM1, int DIM2, type* IN_ARRAY2) typemap @@ -106,7 +106,7 @@ class MatrixTestCase(unittest.TestCase): "Test min function with bad list" print(self.typeStr, "... ", end=' ', file=sys.stderr) min = Matrix.__dict__[self.typeStr + "Min"] - matrix = [["nine","eight"], ["seven","six"]] + matrix = [["nine", "eight"], ["seven", "six"]] self.assertRaises(BadListError, min, matrix) # Test (int DIM1, int DIM2, type* IN_ARRAY2) typemap @@ -114,7 +114,7 @@ class MatrixTestCase(unittest.TestCase): "Test min function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) min = Matrix.__dict__[self.typeStr + "Min"] - self.assertRaises(TypeError, min, [1,3,5,7,9]) + self.assertRaises(TypeError, min, [1, 3, 5, 7, 9]) # Test (int DIM1, int DIM2, type* IN_ARRAY2) typemap def testMinNonContainer(self): @@ -128,16 +128,16 @@ class MatrixTestCase(unittest.TestCase): "Test scale function" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Matrix.__dict__[self.typeStr + "Scale"] - matrix = np.array([[1,2,3],[2,1,2],[3,2,1]],self.typeCode) - scale(matrix,4) - self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True) + matrix = np.array([[1, 2, 3], [2, 1, 2], [3, 2, 1]], self.typeCode) + scale(matrix, 4) + self.assertEquals((matrix == [[4, 8, 12], [8, 4, 8], [12, 8, 4]]).all(), True) # Test (type INPLACE_ARRAY2[ANY][ANY]) typemap def testScaleWrongDim(self): "Test scale function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Matrix.__dict__[self.typeStr + "Scale"] - matrix = np.array([1,2,2,1],self.typeCode) + matrix = np.array([1, 2, 2, 1], self.typeCode) self.assertRaises(TypeError, scale, matrix) # Test (type INPLACE_ARRAY2[ANY][ANY]) typemap @@ -145,7 +145,7 @@ class MatrixTestCase(unittest.TestCase): "Test scale function with wrong size" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Matrix.__dict__[self.typeStr + "Scale"] - matrix = np.array([[1,2],[2,1]],self.typeCode) + matrix = np.array([[1, 2], [2, 1]], self.typeCode) self.assertRaises(TypeError, scale, matrix) # Test (type INPLACE_ARRAY2[ANY][ANY]) typemap @@ -153,7 +153,7 @@ class MatrixTestCase(unittest.TestCase): "Test scale function with wrong type" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Matrix.__dict__[self.typeStr + "Scale"] - matrix = np.array([[1,2,3],[2,1,2],[3,2,1]],'c') + matrix = np.array([[1, 2, 3], [2, 1, 2], [3, 2, 1]], 'c') self.assertRaises(TypeError, scale, matrix) # Test (type INPLACE_ARRAY2[ANY][ANY]) typemap @@ -161,7 +161,7 @@ class MatrixTestCase(unittest.TestCase): "Test scale function with non-array" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Matrix.__dict__[self.typeStr + "Scale"] - matrix = [[1,2,3],[2,1,2],[3,2,1]] + matrix = [[1, 2, 3], [2, 1, 2], [3, 2, 1]] self.assertRaises(TypeError, scale, matrix) # Test (type* INPLACE_ARRAY2, int DIM1, int DIM2) typemap @@ -169,16 +169,16 @@ class MatrixTestCase(unittest.TestCase): "Test floor function" print(self.typeStr, "... ", end=' ', file=sys.stderr) floor = Matrix.__dict__[self.typeStr + "Floor"] - matrix = np.array([[6,7],[8,9]],self.typeCode) - floor(matrix,7) - np.testing.assert_array_equal(matrix, np.array([[7,7],[8,9]])) + matrix = np.array([[6, 7], [8, 9]], self.typeCode) + floor(matrix, 7) + np.testing.assert_array_equal(matrix, np.array([[7, 7], [8, 9]])) # Test (type* INPLACE_ARRAY2, int DIM1, int DIM2) typemap def testFloorWrongDim(self): "Test floor function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) floor = Matrix.__dict__[self.typeStr + "Floor"] - matrix = np.array([6,7,8,9],self.typeCode) + matrix = np.array([6, 7, 8, 9], self.typeCode) self.assertRaises(TypeError, floor, matrix) # Test (type* INPLACE_ARRAY2, int DIM1, int DIM2) typemap @@ -186,7 +186,7 @@ class MatrixTestCase(unittest.TestCase): "Test floor function with wrong type" print(self.typeStr, "... ", end=' ', file=sys.stderr) floor = Matrix.__dict__[self.typeStr + "Floor"] - matrix = np.array([[6,7], [8,9]],'c') + matrix = np.array([[6, 7], [8, 9]], 'c') self.assertRaises(TypeError, floor, matrix) # Test (type* INPLACE_ARRAY2, int DIM1, int DIM2) typemap @@ -194,7 +194,7 @@ class MatrixTestCase(unittest.TestCase): "Test floor function with non-array" print(self.typeStr, "... ", end=' ', file=sys.stderr) floor = Matrix.__dict__[self.typeStr + "Floor"] - matrix = [[6,7], [8,9]] + matrix = [[6, 7], [8, 9]] self.assertRaises(TypeError, floor, matrix) # Test (int DIM1, int DIM2, type* INPLACE_ARRAY2) typemap @@ -202,16 +202,16 @@ class MatrixTestCase(unittest.TestCase): "Test ceil function" print(self.typeStr, "... ", end=' ', file=sys.stderr) ceil = Matrix.__dict__[self.typeStr + "Ceil"] - matrix = np.array([[1,2],[3,4]],self.typeCode) - ceil(matrix,3) - np.testing.assert_array_equal(matrix, np.array([[1,2],[3,3]])) + matrix = np.array([[1, 2], [3, 4]], self.typeCode) + ceil(matrix, 3) + np.testing.assert_array_equal(matrix, np.array([[1, 2], [3, 3]])) # Test (int DIM1, int DIM2, type* INPLACE_ARRAY2) typemap def testCeilWrongDim(self): "Test ceil function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) ceil = Matrix.__dict__[self.typeStr + "Ceil"] - matrix = np.array([1,2,3,4],self.typeCode) + matrix = np.array([1, 2, 3, 4], self.typeCode) self.assertRaises(TypeError, ceil, matrix) # Test (int DIM1, int DIM2, type* INPLACE_ARRAY2) typemap @@ -219,7 +219,7 @@ class MatrixTestCase(unittest.TestCase): "Test ceil function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) ceil = Matrix.__dict__[self.typeStr + "Ceil"] - matrix = np.array([[1,2], [3,4]],'c') + matrix = np.array([[1, 2], [3, 4]], 'c') self.assertRaises(TypeError, ceil, matrix) # Test (int DIM1, int DIM2, type* INPLACE_ARRAY2) typemap @@ -227,7 +227,7 @@ class MatrixTestCase(unittest.TestCase): "Test ceil function with non-array" print(self.typeStr, "... ", end=' ', file=sys.stderr) ceil = Matrix.__dict__[self.typeStr + "Ceil"] - matrix = [[1,2], [3,4]] + matrix = [[1, 2], [3, 4]] self.assertRaises(TypeError, ceil, matrix) # Test (type ARGOUT_ARRAY2[ANY][ANY]) typemap @@ -235,9 +235,9 @@ class MatrixTestCase(unittest.TestCase): "Test luSplit function" print(self.typeStr, "... ", end=' ', file=sys.stderr) luSplit = Matrix.__dict__[self.typeStr + "LUSplit"] - lower, upper = luSplit([[1,2,3],[4,5,6],[7,8,9]]) - self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True) - self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True) + lower, upper = luSplit([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) + self.assertEquals((lower == [[1, 0, 0], [4, 5, 0], [7, 8, 9]]).all(), True) + self.assertEquals((upper == [[0, 2, 3], [0, 0, 6], [0, 0, 0]]).all(), True) ###################################################################### diff --git a/doc/swig/test/testSuperTensor.py b/doc/swig/test/testSuperTensor.py index f4ae09e76..ff1f86df2 100644 --- a/doc/swig/test/testSuperTensor.py +++ b/doc/swig/test/testSuperTensor.py @@ -30,10 +30,10 @@ class SuperTensorTestCase(unittest.TestCase): "Test norm function" print >>sys.stderr, self.typeStr, "... ", norm = SuperTensor.__dict__[self.typeStr + "Norm"] - supertensor = np.arange(2*2*2*2,dtype=self.typeCode).reshape((2,2,2,2)) + supertensor = np.arange(2*2*2*2, dtype=self.typeCode).reshape((2, 2, 2, 2)) #Note: cludge to get an answer of the same type as supertensor. #Answer is simply sqrt(sum(supertensor*supertensor)/16) - answer = np.array([np.sqrt(np.sum(supertensor.astype('d')*supertensor)/16.)],dtype=self.typeCode)[0] + answer = np.array([np.sqrt(np.sum(supertensor.astype('d')*supertensor)/16.)], dtype=self.typeCode)[0] self.assertAlmostEqual(norm(supertensor), answer, 6) # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap @@ -41,7 +41,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test norm function with bad list" print >>sys.stderr, self.typeStr, "... ", norm = SuperTensor.__dict__[self.typeStr + "Norm"] - supertensor = [[[[0,"one"],[2,3]], [[3,"two"],[1,0]]],[[[0,"one"],[2,3]], [[3,"two"],[1,0]]]] + supertensor = [[[[0, "one"], [2, 3]], [[3, "two"], [1, 0]]], [[[0, "one"], [2, 3]], [[3, "two"], [1, 0]]]] self.assertRaises(BadListError, norm, supertensor) # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap @@ -49,7 +49,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test norm function with wrong dimensions" print >>sys.stderr, self.typeStr, "... ", norm = SuperTensor.__dict__[self.typeStr + "Norm"] - supertensor = np.arange(2*2*2,dtype=self.typeCode).reshape((2,2,2)) + supertensor = np.arange(2*2*2, dtype=self.typeCode).reshape((2, 2, 2)) self.assertRaises(TypeError, norm, supertensor) # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap @@ -57,7 +57,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test norm function with wrong size" print >>sys.stderr, self.typeStr, "... ", norm = SuperTensor.__dict__[self.typeStr + "Norm"] - supertensor = np.arange(3*2*2,dtype=self.typeCode).reshape((3,2,2)) + supertensor = np.arange(3*2*2, dtype=self.typeCode).reshape((3, 2, 2)) self.assertRaises(TypeError, norm, supertensor) # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap @@ -72,7 +72,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test max function" print >>sys.stderr, self.typeStr, "... ", max = SuperTensor.__dict__[self.typeStr + "Max"] - supertensor = [[[[1,2], [3,4]], [[5,6], [7,8]]],[[[1,2], [3,4]], [[5,6], [7,8]]]] + supertensor = [[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]] self.assertEquals(max(supertensor), 8) # Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap @@ -80,7 +80,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test max function with bad list" print >>sys.stderr, self.typeStr, "... ", max = SuperTensor.__dict__[self.typeStr + "Max"] - supertensor = [[[[1,"two"], [3,4]], [[5,"six"], [7,8]]],[[[1,"two"], [3,4]], [[5,"six"], [7,8]]]] + supertensor = [[[[1, "two"], [3, 4]], [[5, "six"], [7, 8]]], [[[1, "two"], [3, 4]], [[5, "six"], [7, 8]]]] self.assertRaises(BadListError, max, supertensor) # Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap @@ -102,7 +102,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test min function" print >>sys.stderr, self.typeStr, "... ", min = SuperTensor.__dict__[self.typeStr + "Min"] - supertensor = [[[[9,8], [7,6]], [[5,4], [3,2]]],[[[9,8], [7,6]], [[5,4], [3,2]]]] + supertensor = [[[[9, 8], [7, 6]], [[5, 4], [3, 2]]], [[[9, 8], [7, 6]], [[5, 4], [3, 2]]]] self.assertEquals(min(supertensor), 2) # Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap @@ -110,7 +110,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test min function with bad list" print >>sys.stderr, self.typeStr, "... ", min = SuperTensor.__dict__[self.typeStr + "Min"] - supertensor = [[[["nine",8], [7,6]], [["five",4], [3,2]]],[[["nine",8], [7,6]], [["five",4], [3,2]]]] + supertensor = [[[["nine", 8], [7, 6]], [["five", 4], [3, 2]]], [[["nine", 8], [7, 6]], [["five", 4], [3, 2]]]] self.assertRaises(BadListError, min, supertensor) # Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap @@ -125,16 +125,16 @@ class SuperTensorTestCase(unittest.TestCase): "Test min function with wrong dimensions" print >>sys.stderr, self.typeStr, "... ", min = SuperTensor.__dict__[self.typeStr + "Min"] - self.assertRaises(TypeError, min, [[1,3],[5,7]]) + self.assertRaises(TypeError, min, [[1, 3], [5, 7]]) # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap def testScale(self): "Test scale function" print >>sys.stderr, self.typeStr, "... ", scale = SuperTensor.__dict__[self.typeStr + "Scale"] - supertensor = np.arange(3*3*3*3,dtype=self.typeCode).reshape((3,3,3,3)) + supertensor = np.arange(3*3*3*3, dtype=self.typeCode).reshape((3, 3, 3, 3)) answer = supertensor.copy()*4 - scale(supertensor,4) + scale(supertensor, 4) self.assertEquals((supertensor == answer).all(), True) # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap @@ -142,9 +142,9 @@ class SuperTensorTestCase(unittest.TestCase): "Test scale function with wrong type" print >>sys.stderr, self.typeStr, "... ", scale = SuperTensor.__dict__[self.typeStr + "Scale"] - supertensor = np.array([[[1,0,1], [0,1,0], [1,0,1]], - [[0,1,0], [1,0,1], [0,1,0]], - [[1,0,1], [0,1,0], [1,0,1]]],'c') + supertensor = np.array([[[1, 0, 1], [0, 1, 0], [1, 0, 1]], + [[0, 1, 0], [1, 0, 1], [0, 1, 0]], + [[1, 0, 1], [0, 1, 0], [1, 0, 1]]], 'c') self.assertRaises(TypeError, scale, supertensor) # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap @@ -152,8 +152,8 @@ class SuperTensorTestCase(unittest.TestCase): "Test scale function with wrong dimensions" print >>sys.stderr, self.typeStr, "... ", scale = SuperTensor.__dict__[self.typeStr + "Scale"] - supertensor = np.array([[1,0,1], [0,1,0], [1,0,1], - [0,1,0], [1,0,1], [0,1,0]],self.typeCode) + supertensor = np.array([[1, 0, 1], [0, 1, 0], [1, 0, 1], + [0, 1, 0], [1, 0, 1], [0, 1, 0]], self.typeCode) self.assertRaises(TypeError, scale, supertensor) # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap @@ -161,9 +161,9 @@ class SuperTensorTestCase(unittest.TestCase): "Test scale function with wrong size" print >>sys.stderr, self.typeStr, "... ", scale = SuperTensor.__dict__[self.typeStr + "Scale"] - supertensor = np.array([[[1,0], [0,1], [1,0]], - [[0,1], [1,0], [0,1]], - [[1,0], [0,1], [1,0]]],self.typeCode) + supertensor = np.array([[[1, 0], [0, 1], [1, 0]], + [[0, 1], [1, 0], [0, 1]], + [[1, 0], [0, 1], [1, 0]]], self.typeCode) self.assertRaises(TypeError, scale, supertensor) # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap @@ -177,12 +177,12 @@ class SuperTensorTestCase(unittest.TestCase): def testFloor(self): "Test floor function" print >>sys.stderr, self.typeStr, "... ", - supertensor = np.arange(2*2*2*2,dtype=self.typeCode).reshape((2,2,2,2)) + supertensor = np.arange(2*2*2*2, dtype=self.typeCode).reshape((2, 2, 2, 2)) answer = supertensor.copy() answer[answer < 4] = 4 floor = SuperTensor.__dict__[self.typeStr + "Floor"] - floor(supertensor,4) + floor(supertensor, 4) np.testing.assert_array_equal(supertensor, answer) # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap @@ -190,7 +190,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test floor function with wrong type" print >>sys.stderr, self.typeStr, "... ", floor = SuperTensor.__dict__[self.typeStr + "Floor"] - supertensor = np.ones(2*2*2*2,dtype='c').reshape((2,2,2,2)) + supertensor = np.ones(2*2*2*2, dtype='c').reshape((2, 2, 2, 2)) self.assertRaises(TypeError, floor, supertensor) # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap @@ -198,7 +198,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test floor function with wrong type" print >>sys.stderr, self.typeStr, "... ", floor = SuperTensor.__dict__[self.typeStr + "Floor"] - supertensor = np.arange(2*2*2,dtype=self.typeCode).reshape((2,2,2)) + supertensor = np.arange(2*2*2, dtype=self.typeCode).reshape((2, 2, 2)) self.assertRaises(TypeError, floor, supertensor) # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap @@ -212,11 +212,11 @@ class SuperTensorTestCase(unittest.TestCase): def testCeil(self): "Test ceil function" print >>sys.stderr, self.typeStr, "... ", - supertensor = np.arange(2*2*2*2,dtype=self.typeCode).reshape((2,2,2,2)) + supertensor = np.arange(2*2*2*2, dtype=self.typeCode).reshape((2, 2, 2, 2)) answer = supertensor.copy() answer[answer > 5] = 5 ceil = SuperTensor.__dict__[self.typeStr + "Ceil"] - ceil(supertensor,5) + ceil(supertensor, 5) np.testing.assert_array_equal(supertensor, answer) # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap @@ -224,7 +224,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test ceil function with wrong type" print >>sys.stderr, self.typeStr, "... ", ceil = SuperTensor.__dict__[self.typeStr + "Ceil"] - supertensor = np.ones(2*2*2*2,'c').reshape((2,2,2,2)) + supertensor = np.ones(2*2*2*2, 'c').reshape((2, 2, 2, 2)) self.assertRaises(TypeError, ceil, supertensor) # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap @@ -232,7 +232,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test ceil function with wrong dimensions" print >>sys.stderr, self.typeStr, "... ", ceil = SuperTensor.__dict__[self.typeStr + "Ceil"] - supertensor = np.arange(2*2*2,dtype=self.typeCode).reshape((2,2,2)) + supertensor = np.arange(2*2*2, dtype=self.typeCode).reshape((2, 2, 2)) self.assertRaises(TypeError, ceil, supertensor) # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap @@ -240,7 +240,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test ceil function with non-array" print >>sys.stderr, self.typeStr, "... ", ceil = SuperTensor.__dict__[self.typeStr + "Ceil"] - supertensor = np.arange(2*2*2*2,dtype=self.typeCode).reshape((2,2,2,2)).tolist() + supertensor = np.arange(2*2*2*2, dtype=self.typeCode).reshape((2, 2, 2, 2)).tolist() self.assertRaises(TypeError, ceil, supertensor) # Test (type ARGOUT_ARRAY3[ANY][ANY][ANY]) typemap @@ -248,7 +248,7 @@ class SuperTensorTestCase(unittest.TestCase): "Test luSplit function" print >>sys.stderr, self.typeStr, "... ", luSplit = SuperTensor.__dict__[self.typeStr + "LUSplit"] - supertensor = np.ones(2*2*2*2,dtype=self.typeCode).reshape((2,2,2,2)) + supertensor = np.ones(2*2*2*2, dtype=self.typeCode).reshape((2, 2, 2, 2)) answer_upper = [[[[0, 0], [0, 1]], [[0, 1], [1, 1]]], [[[0, 1], [1, 1]], [[1, 1], [1, 1]]]] answer_lower = [[[[1, 1], [1, 0]], [[1, 0], [0, 0]]], [[[1, 0], [0, 0]], [[0, 0], [0, 0]]]] lower, upper = luSplit(supertensor) diff --git a/doc/swig/test/testTensor.py b/doc/swig/test/testTensor.py index b6dd2e98a..a9390ebb1 100755 --- a/doc/swig/test/testTensor.py +++ b/doc/swig/test/testTensor.py @@ -31,8 +31,8 @@ class TensorTestCase(unittest.TestCase): "Test norm function" print(self.typeStr, "... ", end=' ', file=sys.stderr) norm = Tensor.__dict__[self.typeStr + "Norm"] - tensor = [[[0,1], [2,3]], - [[3,2], [1,0]]] + tensor = [[[0, 1], [2, 3]], + [[3, 2], [1, 0]]] if isinstance(self.result, int): self.assertEquals(norm(tensor), self.result) else: @@ -43,8 +43,8 @@ class TensorTestCase(unittest.TestCase): "Test norm function with bad list" print(self.typeStr, "... ", end=' ', file=sys.stderr) norm = Tensor.__dict__[self.typeStr + "Norm"] - tensor = [[[0,"one"],[2,3]], - [[3,"two"],[1,0]]] + tensor = [[[0, "one"], [2, 3]], + [[3, "two"], [1, 0]]] self.assertRaises(BadListError, norm, tensor) # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap @@ -52,8 +52,8 @@ class TensorTestCase(unittest.TestCase): "Test norm function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) norm = Tensor.__dict__[self.typeStr + "Norm"] - tensor = [[0,1,2,3], - [3,2,1,0]] + tensor = [[0, 1, 2, 3], + [3, 2, 1, 0]] self.assertRaises(TypeError, norm, tensor) # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap @@ -61,8 +61,8 @@ class TensorTestCase(unittest.TestCase): "Test norm function with wrong size" print(self.typeStr, "... ", end=' ', file=sys.stderr) norm = Tensor.__dict__[self.typeStr + "Norm"] - tensor = [[[0,1,0], [2,3,2]], - [[3,2,3], [1,0,1]]] + tensor = [[[0, 1, 0], [2, 3, 2]], + [[3, 2, 3], [1, 0, 1]]] self.assertRaises(TypeError, norm, tensor) # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap @@ -77,8 +77,8 @@ class TensorTestCase(unittest.TestCase): "Test max function" print(self.typeStr, "... ", end=' ', file=sys.stderr) max = Tensor.__dict__[self.typeStr + "Max"] - tensor = [[[1,2], [3,4]], - [[5,6], [7,8]]] + tensor = [[[1, 2], [3, 4]], + [[5, 6], [7, 8]]] self.assertEquals(max(tensor), 8) # Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap @@ -86,8 +86,8 @@ class TensorTestCase(unittest.TestCase): "Test max function with bad list" print(self.typeStr, "... ", end=' ', file=sys.stderr) max = Tensor.__dict__[self.typeStr + "Max"] - tensor = [[[1,"two"], [3,4]], - [[5,"six"], [7,8]]] + 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 @@ -109,8 +109,8 @@ class TensorTestCase(unittest.TestCase): "Test min function" print(self.typeStr, "... ", end=' ', file=sys.stderr) min = Tensor.__dict__[self.typeStr + "Min"] - tensor = [[[9,8], [7,6]], - [[5,4], [3,2]]] + tensor = [[[9, 8], [7, 6]], + [[5, 4], [3, 2]]] self.assertEquals(min(tensor), 2) # Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap @@ -118,8 +118,8 @@ class TensorTestCase(unittest.TestCase): "Test min function with bad list" print(self.typeStr, "... ", end=' ', file=sys.stderr) min = Tensor.__dict__[self.typeStr + "Min"] - tensor = [[["nine",8], [7,6]], - [["five",4], [3,2]]] + 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 @@ -134,29 +134,29 @@ class TensorTestCase(unittest.TestCase): "Test min function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) min = Tensor.__dict__[self.typeStr + "Min"] - self.assertRaises(TypeError, min, [[1,3],[5,7]]) + self.assertRaises(TypeError, min, [[1, 3], [5, 7]]) # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap def testScale(self): "Test scale function" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Tensor.__dict__[self.typeStr + "Scale"] - tensor = np.array([[[1,0,1], [0,1,0], [1,0,1]], - [[0,1,0], [1,0,1], [0,1,0]], - [[1,0,1], [0,1,0], [1,0,1]]],self.typeCode) - scale(tensor,4) - self.assertEquals((tensor == [[[4,0,4], [0,4,0], [4,0,4]], - [[0,4,0], [4,0,4], [0,4,0]], - [[4,0,4], [0,4,0], [4,0,4]]]).all(), True) + tensor = np.array([[[1, 0, 1], [0, 1, 0], [1, 0, 1]], + [[0, 1, 0], [1, 0, 1], [0, 1, 0]], + [[1, 0, 1], [0, 1, 0], [1, 0, 1]]], self.typeCode) + scale(tensor, 4) + self.assertEquals((tensor == [[[4, 0, 4], [0, 4, 0], [4, 0, 4]], + [[0, 4, 0], [4, 0, 4], [0, 4, 0]], + [[4, 0, 4], [0, 4, 0], [4, 0, 4]]]).all(), True) # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap def testScaleWrongType(self): "Test scale function with wrong type" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Tensor.__dict__[self.typeStr + "Scale"] - tensor = np.array([[[1,0,1], [0,1,0], [1,0,1]], - [[0,1,0], [1,0,1], [0,1,0]], - [[1,0,1], [0,1,0], [1,0,1]]],'c') + tensor = np.array([[[1, 0, 1], [0, 1, 0], [1, 0, 1]], + [[0, 1, 0], [1, 0, 1], [0, 1, 0]], + [[1, 0, 1], [0, 1, 0], [1, 0, 1]]], 'c') self.assertRaises(TypeError, scale, tensor) # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap @@ -164,8 +164,8 @@ class TensorTestCase(unittest.TestCase): "Test scale function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Tensor.__dict__[self.typeStr + "Scale"] - tensor = np.array([[1,0,1], [0,1,0], [1,0,1], - [0,1,0], [1,0,1], [0,1,0]],self.typeCode) + tensor = np.array([[1, 0, 1], [0, 1, 0], [1, 0, 1], + [0, 1, 0], [1, 0, 1], [0, 1, 0]], self.typeCode) self.assertRaises(TypeError, scale, tensor) # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap @@ -173,9 +173,9 @@ class TensorTestCase(unittest.TestCase): "Test scale function with wrong size" print(self.typeStr, "... ", end=' ', file=sys.stderr) scale = Tensor.__dict__[self.typeStr + "Scale"] - tensor = np.array([[[1,0], [0,1], [1,0]], - [[0,1], [1,0], [0,1]], - [[1,0], [0,1], [1,0]]],self.typeCode) + tensor = np.array([[[1, 0], [0, 1], [1, 0]], + [[0, 1], [1, 0], [0, 1]], + [[1, 0], [0, 1], [1, 0]]], self.typeCode) self.assertRaises(TypeError, scale, tensor) # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap @@ -190,19 +190,19 @@ class TensorTestCase(unittest.TestCase): "Test floor function" print(self.typeStr, "... ", end=' ', file=sys.stderr) floor = Tensor.__dict__[self.typeStr + "Floor"] - tensor = np.array([[[1,2], [3,4]], - [[5,6], [7,8]]],self.typeCode) - floor(tensor,4) - np.testing.assert_array_equal(tensor, np.array([[[4,4], [4,4]], - [[5,6], [7,8]]])) + tensor = np.array([[[1, 2], [3, 4]], + [[5, 6], [7, 8]]], self.typeCode) + floor(tensor, 4) + np.testing.assert_array_equal(tensor, np.array([[[4, 4], [4, 4]], + [[5, 6], [7, 8]]])) # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap def testFloorWrongType(self): "Test floor function with wrong type" print(self.typeStr, "... ", end=' ', file=sys.stderr) floor = Tensor.__dict__[self.typeStr + "Floor"] - tensor = np.array([[[1,2], [3,4]], - [[5,6], [7,8]]],'c') + tensor = np.array([[[1, 2], [3, 4]], + [[5, 6], [7, 8]]], 'c') self.assertRaises(TypeError, floor, tensor) # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap @@ -210,7 +210,7 @@ class TensorTestCase(unittest.TestCase): "Test floor function with wrong type" print(self.typeStr, "... ", end=' ', file=sys.stderr) floor = Tensor.__dict__[self.typeStr + "Floor"] - tensor = np.array([[1,2], [3,4], [5,6], [7,8]],self.typeCode) + tensor = np.array([[1, 2], [3, 4], [5, 6], [7, 8]], self.typeCode) self.assertRaises(TypeError, floor, tensor) # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap @@ -225,19 +225,19 @@ class TensorTestCase(unittest.TestCase): "Test ceil function" print(self.typeStr, "... ", end=' ', file=sys.stderr) ceil = Tensor.__dict__[self.typeStr + "Ceil"] - tensor = np.array([[[9,8], [7,6]], - [[5,4], [3,2]]],self.typeCode) - ceil(tensor,5) - np.testing.assert_array_equal(tensor, np.array([[[5,5], [5,5]], - [[5,4], [3,2]]])) + tensor = np.array([[[9, 8], [7, 6]], + [[5, 4], [3, 2]]], self.typeCode) + ceil(tensor, 5) + np.testing.assert_array_equal(tensor, np.array([[[5, 5], [5, 5]], + [[5, 4], [3, 2]]])) # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap def testCeilWrongType(self): "Test ceil function with wrong type" print(self.typeStr, "... ", end=' ', file=sys.stderr) ceil = Tensor.__dict__[self.typeStr + "Ceil"] - tensor = np.array([[[9,8], [7,6]], - [[5,4], [3,2]]],'c') + tensor = np.array([[[9, 8], [7, 6]], + [[5, 4], [3, 2]]], 'c') self.assertRaises(TypeError, ceil, tensor) # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap @@ -245,7 +245,7 @@ class TensorTestCase(unittest.TestCase): "Test ceil function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) ceil = Tensor.__dict__[self.typeStr + "Ceil"] - tensor = np.array([[9,8], [7,6], [5,4], [3,2]], self.typeCode) + tensor = np.array([[9, 8], [7, 6], [5, 4], [3, 2]], self.typeCode) self.assertRaises(TypeError, ceil, tensor) # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap @@ -253,8 +253,8 @@ class TensorTestCase(unittest.TestCase): "Test ceil function with non-array" print(self.typeStr, "... ", end=' ', file=sys.stderr) ceil = Tensor.__dict__[self.typeStr + "Ceil"] - tensor = [[[9,8], [7,6]], - [[5,4], [3,2]]] + tensor = [[[9, 8], [7, 6]], + [[5, 4], [3, 2]]] self.assertRaises(TypeError, ceil, tensor) # Test (type ARGOUT_ARRAY3[ANY][ANY][ANY]) typemap @@ -262,12 +262,12 @@ class TensorTestCase(unittest.TestCase): "Test luSplit function" print(self.typeStr, "... ", end=' ', file=sys.stderr) luSplit = Tensor.__dict__[self.typeStr + "LUSplit"] - lower, upper = luSplit([[[1,1], [1,1]], - [[1,1], [1,1]]]) - self.assertEquals((lower == [[[1,1], [1,0]], - [[1,0], [0,0]]]).all(), True) - self.assertEquals((upper == [[[0,0], [0,1]], - [[0,1], [1,1]]]).all(), True) + lower, upper = luSplit([[[1, 1], [1, 1]], + [[1, 1], [1, 1]]]) + self.assertEquals((lower == [[[1, 1], [1, 0]], + [[1, 0], [0, 0]]]).all(), True) + self.assertEquals((upper == [[[0, 0], [0, 1]], + [[0, 1], [1, 1]]]).all(), True) ###################################################################### diff --git a/doc/swig/test/testVector.py b/doc/swig/test/testVector.py index d644e464c..e7d019cf7 100755 --- a/doc/swig/test/testVector.py +++ b/doc/swig/test/testVector.py @@ -50,7 +50,7 @@ class VectorTestCase(unittest.TestCase): "Test length function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) length = Vector.__dict__[self.typeStr + "Length"] - self.assertRaises(TypeError, length, [[1,2], [3,4]]) + self.assertRaises(TypeError, length, [[1, 2], [3, 4]]) # Test the (type IN_ARRAY1[ANY]) typemap def testLengthNonContainer(self): @@ -64,21 +64,21 @@ class VectorTestCase(unittest.TestCase): "Test prod function" print(self.typeStr, "... ", end=' ', file=sys.stderr) prod = Vector.__dict__[self.typeStr + "Prod"] - self.assertEquals(prod([1,2,3,4]), 24) + 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(self.typeStr, "... ", end=' ', file=sys.stderr) prod = Vector.__dict__[self.typeStr + "Prod"] - self.assertRaises(BadListError, prod, [[1,"two"], ["e","pi"]]) + 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(self.typeStr, "... ", end=' ', file=sys.stderr) prod = Vector.__dict__[self.typeStr + "Prod"] - self.assertRaises(TypeError, prod, [[1,2], [8,9]]) + self.assertRaises(TypeError, prod, [[1, 2], [8, 9]]) # Test the (type* IN_ARRAY1, int DIM1) typemap def testProdNonContainer(self): @@ -92,21 +92,21 @@ class VectorTestCase(unittest.TestCase): "Test sum function" print(self.typeStr, "... ", end=' ', file=sys.stderr) sum = Vector.__dict__[self.typeStr + "Sum"] - self.assertEquals(sum([5,6,7,8]), 26) + 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(self.typeStr, "... ", end=' ', file=sys.stderr) sum = Vector.__dict__[self.typeStr + "Sum"] - self.assertRaises(BadListError, sum, [3,4, 5, "pi"]) + 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(self.typeStr, "... ", end=' ', file=sys.stderr) sum = Vector.__dict__[self.typeStr + "Sum"] - self.assertRaises(TypeError, sum, [[3,4], [5,6]]) + self.assertRaises(TypeError, sum, [[3, 4], [5, 6]]) # Test the (int DIM1, type* IN_ARRAY1) typemap def testSumNonContainer(self): @@ -120,16 +120,16 @@ class VectorTestCase(unittest.TestCase): "Test reverse function" print(self.typeStr, "... ", end=' ', file=sys.stderr) reverse = Vector.__dict__[self.typeStr + "Reverse"] - vector = np.array([1,2,4],self.typeCode) + vector = np.array([1, 2, 4], self.typeCode) reverse(vector) - self.assertEquals((vector == [4,2,1]).all(), True) + self.assertEquals((vector == [4, 2, 1]).all(), True) # Test the (type INPLACE_ARRAY1[ANY]) typemap def testReverseWrongDim(self): "Test reverse function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) reverse = Vector.__dict__[self.typeStr + "Reverse"] - vector = np.array([[1,2], [3,4]],self.typeCode) + vector = np.array([[1, 2], [3, 4]], self.typeCode) self.assertRaises(TypeError, reverse, vector) # Test the (type INPLACE_ARRAY1[ANY]) typemap @@ -137,7 +137,7 @@ class VectorTestCase(unittest.TestCase): "Test reverse function with wrong size" print(self.typeStr, "... ", end=' ', file=sys.stderr) reverse = Vector.__dict__[self.typeStr + "Reverse"] - vector = np.array([9,8,7,6,5,4],self.typeCode) + vector = np.array([9, 8, 7, 6, 5, 4], self.typeCode) self.assertRaises(TypeError, reverse, vector) # Test the (type INPLACE_ARRAY1[ANY]) typemap @@ -145,7 +145,7 @@ class VectorTestCase(unittest.TestCase): "Test reverse function with wrong type" print(self.typeStr, "... ", end=' ', file=sys.stderr) reverse = Vector.__dict__[self.typeStr + "Reverse"] - vector = np.array([1,2,4],'c') + vector = np.array([1, 2, 4], 'c') self.assertRaises(TypeError, reverse, vector) # Test the (type INPLACE_ARRAY1[ANY]) typemap @@ -153,23 +153,23 @@ class VectorTestCase(unittest.TestCase): "Test reverse function with non-array" print(self.typeStr, "... ", end=' ', file=sys.stderr) reverse = Vector.__dict__[self.typeStr + "Reverse"] - self.assertRaises(TypeError, reverse, [2,4,6]) + self.assertRaises(TypeError, reverse, [2, 4, 6]) # Test the (type* INPLACE_ARRAY1, int DIM1) typemap def testOnes(self): "Test ones function" print(self.typeStr, "... ", end=' ', file=sys.stderr) ones = Vector.__dict__[self.typeStr + "Ones"] - vector = np.zeros(5,self.typeCode) + vector = np.zeros(5, self.typeCode) ones(vector) - np.testing.assert_array_equal(vector, np.array([1,1,1,1,1])) + np.testing.assert_array_equal(vector, np.array([1, 1, 1, 1, 1])) # Test the (type* INPLACE_ARRAY1, int DIM1) typemap def testOnesWrongDim(self): "Test ones function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) ones = Vector.__dict__[self.typeStr + "Ones"] - vector = np.zeros((5,5),self.typeCode) + vector = np.zeros((5, 5), self.typeCode) self.assertRaises(TypeError, ones, vector) # Test the (type* INPLACE_ARRAY1, int DIM1) typemap @@ -177,7 +177,7 @@ class VectorTestCase(unittest.TestCase): "Test ones function with wrong type" print(self.typeStr, "... ", end=' ', file=sys.stderr) ones = Vector.__dict__[self.typeStr + "Ones"] - vector = np.zeros((5,5),'c') + vector = np.zeros((5, 5), 'c') self.assertRaises(TypeError, ones, vector) # Test the (type* INPLACE_ARRAY1, int DIM1) typemap @@ -185,23 +185,23 @@ class VectorTestCase(unittest.TestCase): "Test ones function with non-array" print(self.typeStr, "... ", end=' ', file=sys.stderr) ones = Vector.__dict__[self.typeStr + "Ones"] - self.assertRaises(TypeError, ones, [2,4,6,8]) + self.assertRaises(TypeError, ones, [2, 4, 6, 8]) # Test the (int DIM1, type* INPLACE_ARRAY1) typemap def testZeros(self): "Test zeros function" print(self.typeStr, "... ", end=' ', file=sys.stderr) zeros = Vector.__dict__[self.typeStr + "Zeros"] - vector = np.ones(5,self.typeCode) + vector = np.ones(5, self.typeCode) zeros(vector) - np.testing.assert_array_equal(vector, np.array([0,0,0,0,0])) + np.testing.assert_array_equal(vector, np.array([0, 0, 0, 0, 0])) # Test the (int DIM1, type* INPLACE_ARRAY1) typemap def testZerosWrongDim(self): "Test zeros function with wrong dimensions" print(self.typeStr, "... ", end=' ', file=sys.stderr) zeros = Vector.__dict__[self.typeStr + "Zeros"] - vector = np.ones((5,5),self.typeCode) + vector = np.ones((5, 5), self.typeCode) self.assertRaises(TypeError, zeros, vector) # Test the (int DIM1, type* INPLACE_ARRAY1) typemap @@ -209,7 +209,7 @@ class VectorTestCase(unittest.TestCase): "Test zeros function with wrong type" print(self.typeStr, "... ", end=' ', file=sys.stderr) zeros = Vector.__dict__[self.typeStr + "Zeros"] - vector = np.ones(6,'c') + vector = np.ones(6, 'c') self.assertRaises(TypeError, zeros, vector) # Test the (int DIM1, type* INPLACE_ARRAY1) typemap @@ -217,16 +217,16 @@ class VectorTestCase(unittest.TestCase): "Test zeros function with non-array" print(self.typeStr, "... ", end=' ', file=sys.stderr) zeros = Vector.__dict__[self.typeStr + "Zeros"] - self.assertRaises(TypeError, zeros, [1,3,5,7,9]) + self.assertRaises(TypeError, zeros, [1, 3, 5, 7, 9]) # Test the (type ARGOUT_ARRAY1[ANY]) typemap def testEOSplit(self): "Test eoSplit function" print(self.typeStr, "... ", end=' ', file=sys.stderr) eoSplit = Vector.__dict__[self.typeStr + "EOSplit"] - even, odd = eoSplit([1,2,3]) - self.assertEquals((even == [1,0,3]).all(), True) - self.assertEquals((odd == [0,2,0]).all(), True) + even, odd = eoSplit([1, 2, 3]) + self.assertEquals((even == [1, 0, 3]).all(), True) + self.assertEquals((odd == [0, 2, 0]).all(), True) # Test the (type* ARGOUT_ARRAY1, int DIM1) typemap def testTwos(self): @@ -234,7 +234,7 @@ class VectorTestCase(unittest.TestCase): print(self.typeStr, "... ", end=' ', file=sys.stderr) twos = Vector.__dict__[self.typeStr + "Twos"] vector = twos(5) - self.assertEquals((vector == [2,2,2,2,2]).all(), True) + self.assertEquals((vector == [2, 2, 2, 2, 2]).all(), True) # Test the (type* ARGOUT_ARRAY1, int DIM1) typemap def testTwosNonInt(self): @@ -249,7 +249,7 @@ class VectorTestCase(unittest.TestCase): print(self.typeStr, "... ", end=' ', file=sys.stderr) threes = Vector.__dict__[self.typeStr + "Threes"] vector = threes(6) - self.assertEquals((vector == [3,3,3,3,3,3]).all(), True) + self.assertEquals((vector == [3, 3, 3, 3, 3, 3]).all(), True) # Test the (type* ARGOUT_ARRAY1, int DIM1) typemap def testThreesNonInt(self): |