/[escript]/trunk/escript/py_src/test_util_unary_no_tagged_data.py
ViewVC logotype

Diff of /trunk/escript/py_src/test_util_unary_no_tagged_data.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 535 by gross, Wed Feb 15 07:11:00 2006 UTC revision 536 by gross, Fri Feb 17 03:20:53 2006 UTC
# Line 6241  class Test_util_unary_no_tagged_data(Tes Line 6241  class Test_util_unary_no_tagged_data(Tes
6241        self.failUnless(isinstance(res,Data),"wrong type of result.")        self.failUnless(isinstance(res,Data),"wrong type of result.")
6242        self.failUnlessEqual(res.getShape(),(3,),"wrong shape of result.")        self.failUnlessEqual(res.getShape(),(3,),"wrong shape of result.")
6243        self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")        self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6244       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6245       def test_symmetric_array_rank2(self):
6246          arg=numarray.array([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]])
6247          res=symmetric(arg)
6248          ref=numarray.array([[0.0, 2.0, 4.0], [2.0, 4.0, 6.0], [4.0, 6.0, 8.0]])
6249          self.failUnless(isinstance(res,numarray.NumArray),"wrong type of result.")
6250          self.failUnlessEqual(res.shape,(3, 3),"wrong shape of result.")
6251          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6252       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6253       def test_symmetric_array_rank4(self):
6254          arg=numarray.array([[[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]], [[6.0, 7.0, 8.0], [9.0, 10.0, 11.0]], [[12.0, 13.0, 14.0], [15.0, 16.0, 17.0]]], [[[18.0, 19.0, 20.0], [21.0, 22.0, 23.0]], [[24.0, 25.0, 26.0], [27.0, 28.0, 29.0]], [[30.0, 31.0, 32.0], [33.0, 34.0, 35.0]]]])
6255          res=symmetric(arg)
6256          ref=numarray.array([[[[0.0, 3.5, 7.0], [10.5, 14.0, 17.5]], [[3.5, 7.0, 10.5], [14.0, 17.5, 21.0]], [[7.0, 10.5, 14.0], [17.5, 21.0, 24.5]]], [[[10.5, 14.0, 17.5], [21.0, 24.5, 28.0]], [[14.0, 17.5, 21.0], [24.5, 28.0, 31.5]], [[17.5, 21.0, 24.5], [28.0, 31.5, 35.0]]]])
6257          self.failUnless(isinstance(res,numarray.NumArray),"wrong type of result.")
6258          self.failUnlessEqual(res.shape,(2, 3, 2, 3),"wrong shape of result.")
6259          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6260       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6261       def test_symmetric_Symbol_rank2(self):
6262          arg=Symbol(shape=(3, 3))
6263          res=symmetric(arg)
6264          s=numarray.array([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]])
6265          sub=res.substitute({arg:s})
6266          ref=numarray.array([[0.0, 2.0, 4.0], [2.0, 4.0, 6.0], [4.0, 6.0, 8.0]])
6267          self.failUnless(isinstance(res,Symbol),"wrong type of result.")
6268          self.failUnlessEqual(res.getShape(),(3, 3),"wrong shape of result.")
6269          self.failUnless(Lsup(sub-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6270       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6271       def test_symmetric_Symbol_rank4(self):
6272          arg=Symbol(shape=(2, 3, 2, 3))
6273          res=symmetric(arg)
6274          s=numarray.array([[[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]], [[6.0, 7.0, 8.0], [9.0, 10.0, 11.0]], [[12.0, 13.0, 14.0], [15.0, 16.0, 17.0]]], [[[18.0, 19.0, 20.0], [21.0, 22.0, 23.0]], [[24.0, 25.0, 26.0], [27.0, 28.0, 29.0]], [[30.0, 31.0, 32.0], [33.0, 34.0, 35.0]]]])
6275          sub=res.substitute({arg:s})
6276          ref=numarray.array([[[[0.0, 3.5, 7.0], [10.5, 14.0, 17.5]], [[3.5, 7.0, 10.5], [14.0, 17.5, 21.0]], [[7.0, 10.5, 14.0], [17.5, 21.0, 24.5]]], [[[10.5, 14.0, 17.5], [21.0, 24.5, 28.0]], [[14.0, 17.5, 21.0], [24.5, 28.0, 31.5]], [[17.5, 21.0, 24.5], [28.0, 31.5, 35.0]]]])
6277          self.failUnless(isinstance(res,Symbol),"wrong type of result.")
6278          self.failUnlessEqual(res.getShape(),(2, 3, 2, 3),"wrong shape of result.")
6279          self.failUnless(Lsup(sub-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6280       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6281       def test_symmetric_constData_rank2(self):
6282          arg=Data(numarray.array([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]]),self.functionspace)
6283          res=symmetric(arg)
6284          ref=Data(numarray.array([[0.0, 2.0, 4.0], [2.0, 4.0, 6.0], [4.0, 6.0, 8.0]]),self.functionspace)
6285          self.failUnless(isinstance(res,Data),"wrong type of result.")
6286          self.failUnlessEqual(res.getShape(),(3, 3),"wrong shape of result.")
6287          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6288       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6289       def test_symmetric_constData_rank4(self):
6290          arg=Data(numarray.array([[[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]], [[6.0, 7.0, 8.0], [9.0, 10.0, 11.0]], [[12.0, 13.0, 14.0], [15.0, 16.0, 17.0]]], [[[18.0, 19.0, 20.0], [21.0, 22.0, 23.0]], [[24.0, 25.0, 26.0], [27.0, 28.0, 29.0]], [[30.0, 31.0, 32.0], [33.0, 34.0, 35.0]]]]),self.functionspace)
6291          res=symmetric(arg)
6292          ref=Data(numarray.array([[[[0.0, 3.5, 7.0], [10.5, 14.0, 17.5]], [[3.5, 7.0, 10.5], [14.0, 17.5, 21.0]], [[7.0, 10.5, 14.0], [17.5, 21.0, 24.5]]], [[[10.5, 14.0, 17.5], [21.0, 24.5, 28.0]], [[14.0, 17.5, 21.0], [24.5, 28.0, 31.5]], [[17.5, 21.0, 24.5], [28.0, 31.5, 35.0]]]]),self.functionspace)
6293          self.failUnless(isinstance(res,Data),"wrong type of result.")
6294          self.failUnlessEqual(res.getShape(),(2, 3, 2, 3),"wrong shape of result.")
6295          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6296       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6297       def test_symmetric_expandedData_rank2(self):
6298          msk_arg=whereNegative(self.functionspace.getX()[0]-0.5)
6299          arg=msk_arg*numarray.array([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]])+(1.-msk_arg)*numarray.array([[-0.0, -1.0, -2.0], [-3.0, -4.0, -5.0], [-6.0, -7.0, -8.0]])
6300          res=symmetric(arg)
6301          msk_ref=whereNegative(self.functionspace.getX()[0]-0.5)
6302          ref=msk_ref*numarray.array([[0.0, 2.0, 4.0], [2.0, 4.0, 6.0], [4.0, 6.0, 8.0]])+(1.-msk_ref)*numarray.array([[-0.0, -2.0, -4.0], [-2.0, -4.0, -6.0], [-4.0, -6.0, -8.0]])
6303          self.failUnless(isinstance(res,Data),"wrong type of result.")
6304          self.failUnlessEqual(res.getShape(),(3, 3),"wrong shape of result.")
6305          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6306       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6307       def test_symmetric_expandedData_rank4(self):
6308          msk_arg=whereNegative(self.functionspace.getX()[0]-0.5)
6309          arg=msk_arg*numarray.array([[[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]], [[6.0, 7.0, 8.0], [9.0, 10.0, 11.0]], [[12.0, 13.0, 14.0], [15.0, 16.0, 17.0]]], [[[18.0, 19.0, 20.0], [21.0, 22.0, 23.0]], [[24.0, 25.0, 26.0], [27.0, 28.0, 29.0]], [[30.0, 31.0, 32.0], [33.0, 34.0, 35.0]]]])+(1.-msk_arg)*numarray.array([[[[-0.0, -1.0, -2.0], [-3.0, -4.0, -5.0]], [[-6.0, -7.0, -8.0], [-9.0, -10.0, -11.0]], [[-12.0, -13.0, -14.0], [-15.0, -16.0, -17.0]]], [[[-18.0, -19.0, -20.0], [-21.0, -22.0, -23.0]], [[-24.0, -25.0, -26.0], [-27.0, -28.0, -29.0]], [[-30.0, -31.0, -32.0], [-33.0, -34.0, -35.0]]]])
6310          res=symmetric(arg)
6311          msk_ref=whereNegative(self.functionspace.getX()[0]-0.5)
6312          ref=msk_ref*numarray.array([[[[0.0, 3.5, 7.0], [10.5, 14.0, 17.5]], [[3.5, 7.0, 10.5], [14.0, 17.5, 21.0]], [[7.0, 10.5, 14.0], [17.5, 21.0, 24.5]]], [[[10.5, 14.0, 17.5], [21.0, 24.5, 28.0]], [[14.0, 17.5, 21.0], [24.5, 28.0, 31.5]], [[17.5, 21.0, 24.5], [28.0, 31.5, 35.0]]]])+(1.-msk_ref)*numarray.array([[[[-0.0, -3.5, -7.0], [-10.5, -14.0, -17.5]], [[-3.5, -7.0, -10.5], [-14.0, -17.5, -21.0]], [[-7.0, -10.5, -14.0], [-17.5, -21.0, -24.5]]], [[[-10.5, -14.0, -17.5], [-21.0, -24.5, -28.0]], [[-14.0, -17.5, -21.0], [-24.5, -28.0, -31.5]], [[-17.5, -21.0, -24.5], [-28.0, -31.5, -35.0]]]])
6313          self.failUnless(isinstance(res,Data),"wrong type of result.")
6314          self.failUnlessEqual(res.getShape(),(2, 3, 2, 3),"wrong shape of result.")
6315          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6316       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6317       def test_nonsymmetric_array_rank2(self):
6318          arg=numarray.array([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]])
6319          res=nonsymmetric(arg)
6320          ref=numarray.array([[0.0, -1.0, -2.0], [1.0, 0.0, -1.0], [2.0, 1.0, 0.0]])
6321          self.failUnless(isinstance(res,numarray.NumArray),"wrong type of result.")
6322          self.failUnlessEqual(res.shape,(3, 3),"wrong shape of result.")
6323          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6324       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6325       def test_nonsymmetric_array_rank4(self):
6326          arg=numarray.array([[[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]], [[6.0, 7.0, 8.0], [9.0, 10.0, 11.0]], [[12.0, 13.0, 14.0], [15.0, 16.0, 17.0]]], [[[18.0, 19.0, 20.0], [21.0, 22.0, 23.0]], [[24.0, 25.0, 26.0], [27.0, 28.0, 29.0]], [[30.0, 31.0, 32.0], [33.0, 34.0, 35.0]]]])
6327          res=nonsymmetric(arg)
6328          ref=numarray.array([[[[0.0, -2.5, -5.0], [-7.5, -10.0, -12.5]], [[2.5, 0.0, -2.5], [-5.0, -7.5, -10.0]], [[5.0, 2.5, 0.0], [-2.5, -5.0, -7.5]]], [[[7.5, 5.0, 2.5], [0.0, -2.5, -5.0]], [[10.0, 7.5, 5.0], [2.5, 0.0, -2.5]], [[12.5, 10.0, 7.5], [5.0, 2.5, 0.0]]]])
6329          self.failUnless(isinstance(res,numarray.NumArray),"wrong type of result.")
6330          self.failUnlessEqual(res.shape,(2, 3, 2, 3),"wrong shape of result.")
6331          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6332       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6333       def test_nonsymmetric_Symbol_rank2(self):
6334          arg=Symbol(shape=(3, 3))
6335          res=nonsymmetric(arg)
6336          s=numarray.array([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]])
6337          sub=res.substitute({arg:s})
6338          ref=numarray.array([[0.0, -1.0, -2.0], [1.0, 0.0, -1.0], [2.0, 1.0, 0.0]])
6339          self.failUnless(isinstance(res,Symbol),"wrong type of result.")
6340          self.failUnlessEqual(res.getShape(),(3, 3),"wrong shape of result.")
6341          self.failUnless(Lsup(sub-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6342       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6343       def test_nonsymmetric_Symbol_rank4(self):
6344          arg=Symbol(shape=(2, 3, 2, 3))
6345          res=nonsymmetric(arg)
6346          s=numarray.array([[[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]], [[6.0, 7.0, 8.0], [9.0, 10.0, 11.0]], [[12.0, 13.0, 14.0], [15.0, 16.0, 17.0]]], [[[18.0, 19.0, 20.0], [21.0, 22.0, 23.0]], [[24.0, 25.0, 26.0], [27.0, 28.0, 29.0]], [[30.0, 31.0, 32.0], [33.0, 34.0, 35.0]]]])
6347          sub=res.substitute({arg:s})
6348          ref=numarray.array([[[[0.0, -2.5, -5.0], [-7.5, -10.0, -12.5]], [[2.5, 0.0, -2.5], [-5.0, -7.5, -10.0]], [[5.0, 2.5, 0.0], [-2.5, -5.0, -7.5]]], [[[7.5, 5.0, 2.5], [0.0, -2.5, -5.0]], [[10.0, 7.5, 5.0], [2.5, 0.0, -2.5]], [[12.5, 10.0, 7.5], [5.0, 2.5, 0.0]]]])
6349          self.failUnless(isinstance(res,Symbol),"wrong type of result.")
6350          self.failUnlessEqual(res.getShape(),(2, 3, 2, 3),"wrong shape of result.")
6351          self.failUnless(Lsup(sub-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6352       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6353       def test_nonsymmetric_constData_rank2(self):
6354          arg=Data(numarray.array([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]]),self.functionspace)
6355          res=nonsymmetric(arg)
6356          ref=Data(numarray.array([[0.0, -1.0, -2.0], [1.0, 0.0, -1.0], [2.0, 1.0, 0.0]]),self.functionspace)
6357          self.failUnless(isinstance(res,Data),"wrong type of result.")
6358          self.failUnlessEqual(res.getShape(),(3, 3),"wrong shape of result.")
6359          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6360       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6361       def test_nonsymmetric_constData_rank4(self):
6362          arg=Data(numarray.array([[[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]], [[6.0, 7.0, 8.0], [9.0, 10.0, 11.0]], [[12.0, 13.0, 14.0], [15.0, 16.0, 17.0]]], [[[18.0, 19.0, 20.0], [21.0, 22.0, 23.0]], [[24.0, 25.0, 26.0], [27.0, 28.0, 29.0]], [[30.0, 31.0, 32.0], [33.0, 34.0, 35.0]]]]),self.functionspace)
6363          res=nonsymmetric(arg)
6364          ref=Data(numarray.array([[[[0.0, -2.5, -5.0], [-7.5, -10.0, -12.5]], [[2.5, 0.0, -2.5], [-5.0, -7.5, -10.0]], [[5.0, 2.5, 0.0], [-2.5, -5.0, -7.5]]], [[[7.5, 5.0, 2.5], [0.0, -2.5, -5.0]], [[10.0, 7.5, 5.0], [2.5, 0.0, -2.5]], [[12.5, 10.0, 7.5], [5.0, 2.5, 0.0]]]]),self.functionspace)
6365          self.failUnless(isinstance(res,Data),"wrong type of result.")
6366          self.failUnlessEqual(res.getShape(),(2, 3, 2, 3),"wrong shape of result.")
6367          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6368       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6369       def test_nonsymmetric_expandedData_rank2(self):
6370          msk_arg=whereNegative(self.functionspace.getX()[0]-0.5)
6371          arg=msk_arg*numarray.array([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]])+(1.-msk_arg)*numarray.array([[-0.0, -1.0, -2.0], [-3.0, -4.0, -5.0], [-6.0, -7.0, -8.0]])
6372          res=nonsymmetric(arg)
6373          msk_ref=whereNegative(self.functionspace.getX()[0]-0.5)
6374          ref=msk_ref*numarray.array([[0.0, -1.0, -2.0], [1.0, 0.0, -1.0], [2.0, 1.0, 0.0]])+(1.-msk_ref)*numarray.array([[0.0, 1.0, 2.0], [-1.0, 0.0, 1.0], [-2.0, -1.0, 0.0]])
6375          self.failUnless(isinstance(res,Data),"wrong type of result.")
6376          self.failUnlessEqual(res.getShape(),(3, 3),"wrong shape of result.")
6377          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
6378       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6379       def test_nonsymmetric_expandedData_rank4(self):
6380          msk_arg=whereNegative(self.functionspace.getX()[0]-0.5)
6381          arg=msk_arg*numarray.array([[[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]], [[6.0, 7.0, 8.0], [9.0, 10.0, 11.0]], [[12.0, 13.0, 14.0], [15.0, 16.0, 17.0]]], [[[18.0, 19.0, 20.0], [21.0, 22.0, 23.0]], [[24.0, 25.0, 26.0], [27.0, 28.0, 29.0]], [[30.0, 31.0, 32.0], [33.0, 34.0, 35.0]]]])+(1.-msk_arg)*numarray.array([[[[-0.0, -1.0, -2.0], [-3.0, -4.0, -5.0]], [[-6.0, -7.0, -8.0], [-9.0, -10.0, -11.0]], [[-12.0, -13.0, -14.0], [-15.0, -16.0, -17.0]]], [[[-18.0, -19.0, -20.0], [-21.0, -22.0, -23.0]], [[-24.0, -25.0, -26.0], [-27.0, -28.0, -29.0]], [[-30.0, -31.0, -32.0], [-33.0, -34.0, -35.0]]]])
6382          res=nonsymmetric(arg)
6383          msk_ref=whereNegative(self.functionspace.getX()[0]-0.5)
6384          ref=msk_ref*numarray.array([[[[0.0, -2.5, -5.0], [-7.5, -10.0, -12.5]], [[2.5, 0.0, -2.5], [-5.0, -7.5, -10.0]], [[5.0, 2.5, 0.0], [-2.5, -5.0, -7.5]]], [[[7.5, 5.0, 2.5], [0.0, -2.5, -5.0]], [[10.0, 7.5, 5.0], [2.5, 0.0, -2.5]], [[12.5, 10.0, 7.5], [5.0, 2.5, 0.0]]]])+(1.-msk_ref)*numarray.array([[[[0.0, 2.5, 5.0], [7.5, 10.0, 12.5]], [[-2.5, 0.0, 2.5], [5.0, 7.5, 10.0]], [[-5.0, -2.5, 0.0], [2.5, 5.0, 7.5]]], [[[-7.5, -5.0, -2.5], [0.0, 2.5, 5.0]], [[-10.0, -7.5, -5.0], [-2.5, 0.0, 2.5]], [[-12.5, -10.0, -7.5], [-5.0, -2.5, 0.0]]]])
6385          self.failUnless(isinstance(res,Data),"wrong type of result.")
6386          self.failUnlessEqual(res.getShape(),(2, 3, 2, 3),"wrong shape of result.")
6387          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")

Legend:
Removed from v.535  
changed lines
  Added in v.536

  ViewVC Help
Powered by ViewVC 1.1.26