From: Anthony Geay Date: Wed, 28 Dec 2022 07:37:01 +0000 (+0100) Subject: [EDF26665] : MEDFileFieldMultiTS.setInfo added in Python wrapping of MEDLoader X-Git-Tag: V9_11_0a1~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=57f3c28bfda19b1707ab7bed5b9d869e6422f4a4;p=tools%2Fmedcoupling.git [EDF26665] : MEDFileFieldMultiTS.setInfo added in Python wrapping of MEDLoader --- diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 4befee342..9bfac569f 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -2674,6 +2674,7 @@ namespace MEDCoupling void setDtUnit(const std::string& dtUnit); std::string getMeshName() const; void setMeshName(const std::string& newMeshName); + void setInfo(const std::vector& infos); const std::vector& getInfo() const; bool presenceOfMultiDiscPerGeoType() const; int getNumberOfComponents() const; diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 6ff02b41a..c0556b16b 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -7073,6 +7073,48 @@ class MEDLoaderTest3(unittest.TestCase): self.assertTrue( m0.isEqual(mm[0],1e-12) ) pass + @WriteInTmpDir + def testFieldMultiTSSetInfo0(self): + """ + [EDF26665] : Test written to check correct behaviour of MEDFileFieldMultiTS.setInfo, lacking in Python wrappers + """ + fname = "Pyfile122.med" + def generateAMEDFileFromScratch(fname,fieldToGenerate): + arr = DataArrayDouble(10) ; arr.iota() + m = MEDCouplingCMesh() ; m.setCoords(arr,arr) + m = m.buildUnstructured() ; m.setName("mesh") + f = MEDCouplingFieldDouble(ON_CELLS) + f.setMesh(m) + f.setName(fieldToGenerate) + arr = DataArrayDouble( f.getNumberOfMeshPlacesExpected() ) + f.setArray(arr) + WriteMesh(fname,m,True) + for i in range(10): + arr[:] = float(i) + 0.1 + f.setTime(float(i) + 0.1, i , 0) + WriteFieldUsingAlreadyWrittenMesh(fname,f) + + + def changeCompoInMEDFile(fname, fnameTarget, fieldToModify): + mfd = MEDFileData(fname) + mfd.getMeshes().write(fnameTarget,2) + fmtsToModify = mfd.getFields().getFieldWithName(fieldToModify) + for f1ts in fmtsToModify: + self.assertTrue( f1ts.getUndergroundDataArray().getInfoOnComponents() != ["Scalars"]) + fmtsToModify.setInfo(["Scalars"]) # <- test is here ! + fmtsToModify.write(fnameTarget,0) + + fieldToModify = "Field122" + generateAMEDFileFromScratch(fname,fieldToModify) + fnameTarget = fname + changeCompoInMEDFile(fname,fnameTarget,fieldToModify) + + fmts = MEDFileFieldMultiTS(fname,fieldToModify) + for f1ts in fmts: + self.assertTrue( f1ts.getUndergroundDataArray().getInfoOnComponents() == ["Scalars"]) + + pass + pass if __name__ == "__main__":