Salome HOME
Boost of expression evaluator DataArrayDouble::applyFunc* + DataArrayDouble::applyFun...
[modules/med.git] / src / MEDCoupling_Swig / MEDCouplingExamplesTest.py
index cf346fa47c80d37b7e49fbeca6f1c0a2551e7887..3b92496751a935eecfa0f2337183f7215bdae4a1 100644 (file)
@@ -1,10 +1,10 @@
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2013  CEA/DEN, EDF R&D
+# Copyright (C) 2007-2014  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -40,12 +40,13 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         field3.setName( "Barycenter" ) # name is necessary!
 
         # WriteVTK
-        fileName = "testExample_MEDCouplingFieldDouble_WriteVTK.vtk"
+        fileName = "testExample_MEDCouplingFieldDouble_WriteVTK"
         fs = [ field1, field2, field3 ] # field series
-        MEDCouplingFieldDouble.WriteVTK( fileName, fs )
+        writtenFileName=MEDCouplingFieldDouble.WriteVTK( fileName, fs )
+       print "The file name with correct extension is : %s"%(writtenFileName)
         #! [PySnippet_MEDCouplingFieldDouble_WriteVTK_1]
         import os
-        os.remove( fileName )   
+        os.remove( writtenFileName )
 
         return
 
@@ -153,8 +154,8 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         array = DataArrayDouble.New( v, 2, 2 ) # 2 tuples per 2 components
         field = MEDCouplingFieldDouble.New( ON_CELLS )
         field.setArray( array )
-        func = "IVec * v + JVec * v*v + 10"
-        field.applyFunc( func )
+        func = "IVec * v + JVec * w*w + 10"
+        field.applyFunc( 2, func )
         self.assertTrue( field.getNumberOfComponents() == 2 ) # 2 components remains
         #! [PySnippet_MEDCouplingFieldDouble_applyFunc_same_nb_comp_1]
         #! [PySnippet_MEDCouplingFieldDouble_applyFunc_same_nb_comp_2]
@@ -2356,7 +2357,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertTrue(d1.isEqual(DataArrayDouble([1.,4.,121.,144.,441.,484.,961.,1681.],4,2),1e-12))
 # ! [PySnippetDataArrayApplyFunc1_2]
 # ! [PySnippetDataArrayApplyFunc1_3]
-        d2=d.applyFunc("smth*IVec+2*smth*JVec")
+        d2=d.applyFunc(2,"smth1*IVec+2*smth2*JVec")
         self.assertTrue(d2.isEqual(DataArrayDouble([1.,4.,11.,24.,21.,44.,31.,82.],4,2),1e-12))
 # ! [PySnippetDataArrayApplyFunc1_3]
 # ! [PySnippetDataArrayApplyFunc1_4]