From 6a3e8b8b574716ad0f79fa89be0f0e627338a2d5 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 16 Oct 2017 13:42:06 +0200 Subject: [PATCH] MEDCoupling module is OK --- src/MEDCoupling_Swig/MEDCouplingCommon.i | 35 +++++++++++++------ .../MEDCouplingIntersectTest.py | 6 ++-- src/MEDCoupling_Swig/MEDCouplingNumPyTest.py | 6 ++-- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index d59771988..02ce39ffd 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -461,6 +461,8 @@ using namespace INTERP_KERNEL; %feature("unref") MEDCouplingFieldDiscretizationGaussNE "$this->decrRef();" %feature("unref") MEDCouplingFieldDiscretizationKriging "$this->decrRef();" %feature("unref") MEDCouplingFieldDouble "$this->decrRef();" +%feature("unref") MEDCouplingFieldFloat "$this->decrRef();" +%feature("unref") MEDCouplingFieldInt "$this->decrRef();" %feature("unref") MEDCouplingMultiFields "$this->decrRef();" %feature("unref") MEDCouplingFieldTemplate "$this->decrRef();" %feature("unref") MEDCouplingMultiFields "$this->decrRef();" @@ -3976,11 +3978,25 @@ namespace MEDCoupling } } }; + + template + class MEDCouplingFieldT : public MEDCoupling::MEDCouplingField + { + public: + TypeOfTimeDiscretization getTimeDiscretization() const throw(INTERP_KERNEL::Exception); + protected: + MEDCouplingFieldT(); + ~MEDCouplingFieldT(); + }; + + %template(DTC3) MEDCoupling::MEDCouplingFieldT; + %template(MEDCouplingFieldTfloat) MEDCoupling::MEDCouplingFieldT; + %template(MEDCouplingFieldTint) MEDCoupling::MEDCouplingFieldT; class MEDCouplingFieldInt; class MEDCouplingFieldFloat; - class MEDCouplingFieldDouble : public MEDCoupling::MEDCouplingField + class MEDCouplingFieldDouble : public MEDCouplingFieldT { public: static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME); @@ -4003,7 +4019,6 @@ namespace MEDCoupling MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCopy) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *nodeToCellDiscretization() const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *cellToNodeDiscretization() const throw(INTERP_KERNEL::Exception); - TypeOfTimeDiscretization getTimeDiscretization() const throw(INTERP_KERNEL::Exception); double getIJ(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception); double getIJK(int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception); void synchronizeTimeWithMesh() throw(INTERP_KERNEL::Exception); @@ -5183,7 +5198,7 @@ namespace MEDCoupling } }; - class MEDCouplingFieldInt : public MEDCouplingField + class MEDCouplingFieldInt : public MEDCouplingFieldT { public: static MEDCouplingFieldInt *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME); @@ -5285,7 +5300,7 @@ namespace MEDCoupling } }; - class MEDCouplingFieldFloat : public MEDCouplingField + class MEDCouplingFieldFloat : public MEDCouplingFieldT { public: static MEDCouplingFieldFloat *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME); @@ -6000,16 +6015,16 @@ def MEDCoupling1DGTUMeshReduce(self): return MEDCouplingStdReduceFunct,(MEDCoupling1DGTUMesh,((),(self.__getstate__()),)) def MEDCouplingFieldDoubleReduce(self): self.checkConsistencyLight() - d={0:(self.getTypeOfField(),self.getTimeDiscretization())} - return MEDCouplingStdReduceFunct,(MEDCouplingFieldDouble,((d,),(self.__getstate__()),)) + d=(self.getTypeOfField(),self.getTimeDiscretization()) + return MEDCouplingStdReduceFunct,(MEDCouplingFieldDouble,(d,(self.__getstate__()),)) def MEDCouplingFieldIntReduce(self): self.checkConsistencyLight() - d={0:(self.getTypeOfField(),self.getTimeDiscretization())} - return MEDCouplingStdReduceFunct,(MEDCouplingFieldInt,((d,),(self.__getstate__()),)) + d=(self.getTypeOfField(),self.getTimeDiscretization()) + return MEDCouplingStdReduceFunct,(MEDCouplingFieldInt,(d,(self.__getstate__()),)) def MEDCouplingFieldFloatReduce(self): self.checkConsistencyLight() - d={0:(self.getTypeOfField(),self.getTimeDiscretization())} - return MEDCouplingStdReduceFunct,(MEDCouplingFieldFloat,((d,),(self.__getstate__()),)) + d=(self.getTypeOfField(),self.getTimeDiscretization()) + return MEDCouplingStdReduceFunct,(MEDCouplingFieldFloat,(d,(self.__getstate__()),)) %} %pythoncode %{ diff --git a/src/MEDCoupling_Swig/MEDCouplingIntersectTest.py b/src/MEDCoupling_Swig/MEDCouplingIntersectTest.py index 833ee9944..bd2e09ad5 100644 --- a/src/MEDCoupling_Swig/MEDCouplingIntersectTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingIntersectTest.py @@ -332,7 +332,7 @@ class MEDCouplingIntersectTest(unittest.TestCase): exp_coo = [9.48750000000001, 9.48750000000001, 10.75249999999975, 9.48749999999955, 10.80629999999976, 9.48749999999955, 9.48749999999961, 10.75249999999971, 10.75249999999338, 10.75249999999338, 10.32506096654411, 10.32506096654411, 9.91493903345591, 10.32506096654411, 9.91493903345591, 9.91493903345591, 10.32506096654411, 9.91493903345591, 10.38162950903903, 10.38162950903903, 9.85837049096099, 10.38162950903903, 9.85837049096099, 9.85837049096099, 10.38162950903903, 9.85837049096099, 10.80629999999339, 10.75249999999338, 9.48749999999961, 10.80629999999971, 10.75249999999338, 10.80629999999339, 10.80629999999339, 10.80629999999339, 9.830000000000023, 10.120000000000008, 10.120000000000008, 10.410000000000004, 10.41000000000001, 10.120000000000008, 10.120000000000008, 9.830000000000013, 9.886654762208451, 10.353345237791569, 9.830000000000023, 10.120000000000008, 9.886654762208451, 9.886654762208451, 9.750000000000005, 10.12000000000001, 9.487499999999809, 10.11999999999986, 9.6729352454803, 10.56706475451937, 9.750000000000005, 10.12000000000001, 9.672935245480499, 9.672935245480499, 9.886654762208451, 9.886654762208451, 10.120000000000008, 9.830000000000013, 10.41000000000001, 10.120000000000008, 10.120000000000008, 10.410000000000004, 9.886654762208451, 10.353345237791569, 10.120000000000013, 10.490000000000004, 10.489999999999988, 10.120000000000013, 10.120000000000017, 9.750000000000021, 10.119999999996494, 10.752499999996544, 10.752499999996566, 10.119999999996466, 10.11999999999988, 9.48749999999978, 9.672935245480499, 9.672935245480499, 10.120000000000017, 9.750000000000021, 10.489999999999988, 10.120000000000013, 10.120000000000013, 10.490000000000004, 9.6729352454803, 10.56706475451937] e1 = [0, 0, 0, 0, 0, 1, 2, 3] e2 = [3, 4, 5, 6, 7, 8, 1, 2] - valuesExpected=DataArrayDouble(exp_coo, len(exp_coo)/2, 2) + valuesExpected=DataArrayDouble(exp_coo, len(exp_coo)//2, 2) self.assertTrue(result.getCoords().isEqual(valuesExpected,1e-12)) self.assertEqual(e1, mapResToInit.getValues()) self.assertEqual(e2, mapResToRef.getValues()) @@ -358,7 +358,7 @@ class MEDCouplingIntersectTest(unittest.TestCase): exp_coo = [9.48749999999998, -10.75249999999999, 9.48750000000018, -10.80629999999998, 10.75250000000047, -10.75250000000063, 10.75249999999318, -10.80629999999318, 10.80630000000048, -10.75250000000063, 10.80629999999318, -10.80629999999318, 9.48750000000001, -9.48750000000001, 10.75249999999975, -9.48750000000004, 10.32506096654408, -9.91493903345589, 9.91493903345589, -9.91493903345589, 9.91493903345589, -10.32506096654409, 10.32506096654408, -10.32506096654409, 10.80629999999976, -9.48750000000004, 10.119999999999989, -10.409999999999961, 9.829999999999997, -10.11999999999999, 10.119999999999983, -9.830000000000005, 10.409999999999968, -10.119999999999987, 9.487499999999994, -10.120000000000001, 9.70121951672795, -9.70121951672795, 9.829999999999997, -10.11999999999999, 9.701219516727935, -10.53878048327204, 10.11999999999988, -9.487500000000026, 10.752500000000111, -10.120000000000335, 10.120000000000225, -10.75250000000031, 9.701219516727935, -10.53878048327204, 10.119999999999989, -10.409999999999961, 10.409999999999968, -10.119999999999987, 10.119999999999983, -9.830000000000005, 9.70121951672795, -9.70121951672795] e1 = [0, 1, 2, 2, 2, 3] e2 = [0, 1, 2, 3, 4, 5] - valuesExpected=DataArrayDouble(exp_coo, len(exp_coo)/2, 2) + valuesExpected=DataArrayDouble(exp_coo, len(exp_coo)//2, 2) self.assertTrue(result.getCoords().isEqual(valuesExpected,1e-10)) self.assertEqual(e1, mapResToInit.getValues()) self.assertEqual(e2, mapResToRef.getValues()) @@ -438,7 +438,7 @@ class MEDCouplingIntersectTest(unittest.TestCase): connI_tgt = [0, 9, 22] res1_tgt = [0, 0] res2_tgt = [0, -1] - self.assert_(coo_tgt.isEqualWithoutConsideringStr(m_intersec.getCoords(), 1e-12)) + self.assertTrue(coo_tgt.isEqualWithoutConsideringStr(m_intersec.getCoords(), 1e-12)) self.assertEqual(conn_tgt, m_intersec.getNodalConnectivity().getValues()) self.assertEqual(connI_tgt, m_intersec.getNodalConnectivityIndex().getValues()) self.assertEqual(res1_tgt, resToM1.getValues()) diff --git a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py index bed6c8fb1..fb621d9d8 100644 --- a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py @@ -386,7 +386,7 @@ class MEDCouplingNumPyTest(unittest.TestCase): def test19(self): sz=20 a=array(0,dtype=int32) - a.resize(sz/2,2) + a.resize(sz//2,2) a[:]=4 self.assertEqual(getrefcount(a),2) d=DataArrayInt(a) @@ -405,7 +405,7 @@ class MEDCouplingNumPyTest(unittest.TestCase): def test20(self): sz=20 a=array(0,dtype=float64) - a.resize(sz/2,2) + a.resize(sz//2,2) a[:]=4 self.assertEqual(getrefcount(a),2) d=DataArrayDouble(a) @@ -918,7 +918,7 @@ class MEDCouplingNumPyTest(unittest.TestCase): """Same as test20 with float32""" sz=20 a=array(0,dtype=float32) - a.resize(sz/2,2) + a.resize(sz//2,2) a[:]=4 self.assertEqual(getrefcount(a),2) d=DataArrayFloat(a) -- 2.39.2