Back to index

salome-med  6.5.0
Public Member Functions
MEDCalculatorBasicsTest.MEDCalculatorBasicsTest Class Reference

List of all members.

Public Member Functions

def test1
def test2
def setUp

Detailed Description

Definition at line 28 of file MEDCalculatorBasicsTest.py.


Member Function Documentation

Definition at line 160 of file MEDCalculatorBasicsTest.py.

00160 
00161     def setUp(self):
        pass

Definition at line 29 of file MEDCalculatorBasicsTest.py.

00029 
00030     def test1(self):
00031         e=MEDCalculatorBrowserLiteStruct("hfile1.med")
00032         f=e.getField(0)
00033         Power=MEDCalculatorDBFieldReal(f)
00034         Power2=Power[:,:,2:4]+Power[:,:,3:5]
00035         Power3=Power[:,:,2:4]+Power(":",":","3:5")
00036         self.assertTrue(Power2.isEqual(Power3,1e-12,1e-12))
00037         Power2=2+Power2
00038         self.assertTrue(not Power2.isEqual(Power3,1e-12,1e-12))
00039         Power2=Power2-2
00040         self.assertTrue(Power2.isEqual(Power3,1e-10,1e-10))
00041         Power2=2*Power2
00042         self.assertTrue(not Power2.isEqual(Power3,1e-12,1e-12))
00043         Power2=Power2/2
00044         self.assertTrue(Power2.isEqual(Power3,1e-12,1e-12))
00045         Power2=Power2*2
00046         Power2.setName('Power2')
00047         Power2.write("hfile2.med",True)
00048         e=MEDCalculatorBrowserLiteStruct("hfile2.med")
00049         f=e.getField(0)
00050         Power4=MEDCalculatorDBFieldReal(f)
00051         self.assertTrue(Power2.isEqual(Power4,1e-12,1e-12))
00052         pass
    

Definition at line 53 of file MEDCalculatorBasicsTest.py.

00053 
00054     def test2(self):
00055         e=MEDCalculatorBrowserLiteStruct("hfile1.med")
00056         f=e.getField(0)
00057         Power=MEDCalculatorDBFieldReal(f)
00058         v=Power.getValues()
00059         self.assertEqual(10,len(v));
00060         for i in xrange(10):
00061             v1=v[i]
00062             self.assertEqual(35,len(v1))
00063             l=0
00064             for j in xrange(5):
00065                 for k in xrange(7):
00066                     self.assertAlmostEqual((i+1)*100.+(j+1)*10.+k+1,v1[l],12);
00067                     l+=1
00068                     pass
00069                 pass
00070             pass
00071         p1=Power[2:4,:,:]
00072         v=p1.getValues()
00073         self.assertEqual(2,len(v));
00074         for i in xrange(2):
00075             v1=v[i]
00076             self.assertEqual(35,len(v1))
00077             l=0
00078             for j in xrange(5):
00079                 for k in xrange(7):
00080                     self.assertAlmostEqual((i+3)*100.+(j+1)*10.+k+1,v1[l],12);
00081                     l+=1
00082                     pass
00083                 pass
00084             pass
00085         p2=Power[3:7,:,2:5]
00086         v=p2.getValues()
00087         self.assertEqual(4,len(v));
00088         for i in xrange(4):
00089             v1=v[i]
00090             self.assertEqual(15,len(v1))
00091             l=0
00092             for j in xrange(5):
00093                 for k in xrange(3):
00094                     self.assertAlmostEqual((i+4)*100.+(j+1)*10.+k+3,v1[l],12);
00095                     l+=1
00096                     pass
00097                 pass
00098             pass
00099         #
00100         p3=Power[0:4,:,2:4].dot(Power[6:,:,3:5])
00101         v=p3.getValues()
00102         self.assertEqual(4,len(v));
00103         expected=[[162192.0, 178952.0, 196112.0, 213672.0, 231632.0], [347792.0, 368552.0, 389712.0, 411272.0, 433232.0], [573392.0, 598152.0, 623312.0, 648872.0, 674832.0], [838992.0, 867752.0, 896912.0, 926472.0, 956432.0]]
00104         for i in xrange(4):
00105             v1=v[i]
00106             self.assertEqual(5,len(v1))
00107             l=0
00108             for j in xrange(5):
00109                 self.assertAlmostEqual(expected[i][j],v1[l],8);
00110                 l+=1
00111                 pass
00112             pass
00113         #
00114         Power[:,:,2:4]=7.
00115         v=Power.getValues()
00116         self.assertEqual(10,len(v));
00117         for i in xrange(10):
00118             v1=v[i]
00119             self.assertEqual(35,len(v1))
00120             l=0
00121             for j in xrange(5):
00122                 for k in xrange(2):
00123                     self.assertAlmostEqual((i+1)*100.+(j+1)*10.+k+1,v1[l],12);
00124                     l+=1
00125                     pass
00126                 self.assertAlmostEqual(7.,v1[l],12);
00127                 l+=1
00128                 self.assertAlmostEqual(7.,v1[l],12);
00129                 l+=1
00130                 for k in xrange(3):
00131                     self.assertAlmostEqual((i+1)*100.+(j+1)*10.+k+5,v1[l],12);
00132                     l+=1
00133                     pass
00134                 pass
00135             pass
00136         Power[1:5,:,3]=p3
00137         v=Power[1:5,:,:].getValues()
00138         self.assertEqual(4,len(v));
00139         for i in xrange(4):
00140             v1=v[i]
00141             self.assertEqual(35,len(v1))
00142             l=0
00143             for j in xrange(5):
00144                 for k in xrange(2):
00145                     self.assertAlmostEqual((i+2)*100.+(j+1)*10.+k+1,v1[l],12);
00146                     l+=1
00147                     pass
00148                 self.assertAlmostEqual(7.,v1[l],12);
00149                 l+=1
00150                 self.assertAlmostEqual(expected[i][j],v1[l],8);
00151                 l+=1
00152                 for k in xrange(3):
00153                     self.assertAlmostEqual((i+2)*100.+(j+1)*10.+k+5,v1[l],12);
00154                     l+=1
00155                     pass
00156                 pass
00157             pass
00158         Power[:,:,1:].eigenValues()
00159         Power[:]=0.07
        pass

Here is the call graph for this function:


The documentation for this class was generated from the following file: