From f426347c8004c0665583b15748630acd4f167450 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 20 Jul 2015 17:16:58 +0200 Subject: [PATCH] Correction of small bug on .__str__ on CurveLinearMesh with spaceDim != meshDim. --- .../MEDCouplingCurveLinearMesh.cxx | 12 +++++++++-- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx index c37e3b203..601ea910d 100644 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx @@ -910,8 +910,16 @@ void MEDCouplingCurveLinearMesh::reprQuickOverview(std::ostream& stream) const { stream << std::endl << "No coordinates set !"; return ; } if(!coo->isAllocated()) { stream << std::endl << "Coordinates set but not allocated !"; return ; } - int nbOfCompo=coo->getNumberOfComponents(); - if(nbOfCompo!=(int)_structure.size()) + int nbOfCompo(coo->getNumberOfComponents()); + int nbOfCompoExp(-1); + try + { + nbOfCompoExp=getSpaceDimension(); + } + catch(INTERP_KERNEL::Exception& e) + { + } + if(nbOfCompo!=nbOfCompoExp) { stream << std::endl << "Coordinates set and allocated but mismatch number of components !"; return ; } stream << std::endl << "Coordinates ( number of tuples = " << coo->getNumberOfTuples() << " ) : "; coo->reprQuickOverviewData(stream,200); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 98c6f9e0c..9fb203dfe 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -16694,6 +16694,26 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(indRef,list(graph.getIndexArray().getValues())); pass + def testSwig2MEDCouplingCurveLinearReprQuick1(self): + """Non regression test. Error in m.__str__ when m is a MEDCouplingCurveLinear with spaceDim != meshDim.""" + arr=DataArrayDouble(12) ; arr.iota() ; arr.rearrange(2) + m=MEDCouplingCurveLinearMesh() + m.setCoords(arr) + m.setNodeGridStructure([3,2]) + m.checkCoherency() + self.assertEqual(m.getMeshDimension(),2) + self.assertEqual(m.getSpaceDimension(),2) + self.assertTrue(not "mismatch" in m.__str__()) + self.assertTrue(not "mismatch" in m.__repr__()) + # + arr=DataArrayDouble(18) ; arr.iota() ; arr.rearrange(3) + m.setCoords(arr) + self.assertEqual(m.getMeshDimension(),2) + self.assertEqual(m.getSpaceDimension(),3) + self.assertTrue(not "mismatch" in m.__str__()) + self.assertTrue(not "mismatch" in m.__repr__())# bug was here ! + pass + pass if __name__ == '__main__': -- 2.39.2