Salome HOME
Numpy optionnal dependancies + getNumberOfCells porting agy/Template2
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 31 May 2017 06:53:02 +0000 (08:53 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 31 May 2017 06:53:02 +0000 (08:53 +0200)
src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx
src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i
src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx

index c22b758dcae67bcff12be988a39cb4623aff0bac..bc3d93680cc80e073cdd6820d3060f7c51388324 100644 (file)
@@ -34,6 +34,7 @@
 #endif
 #endif
 
+#ifdef WITH_NUMPY
 // specific DataArray deallocator callback. This deallocator is used both in the constructor of DataArray and in the toNumPyArr
 // method. This dellocator uses weakref to determine if the linked numArr is still alive or not. If alive the ownership is given to it.
 // if no more alive the "standart" DataArray deallocator is called.
@@ -59,6 +60,7 @@ void numarrdeal(void *pt, void *wron)
     }
   delete [] wronc;
 }
+#endif
 
 template<class MCData>
 struct PyCallBackDataArraySt {
@@ -327,6 +329,7 @@ PyTypeObject PyCallBackDataArrayDouble_RefType = {
   PyObject_GC_Del,            /*tp_free*/
 };
 
+#ifdef WITH_NUMPY
 template<class T>
 struct NPYTraits
 {
@@ -347,5 +350,6 @@ struct NPYTraits<float>
   static PyTypeObject *NPYFunc;
   static PyObject *Array_SWIGTYPE;
 };
+#endif
 
 #endif
index 31c881f06459984973d24815de3e93139cfc2174..8f596420d4ec9165d220cc30667be8469c85961e 100644 (file)
@@ -108,6 +108,7 @@ int InterpreteNegativeInt(int val, int nbelem)
     return val;
 }
 
+#ifdef WITH_NUMPY
 // this is the second type of specific deallocator, only valid for the constructor of DataArrays taking numpy array
 // in input when an another DataArray is already client of this.
 template<class MCData>
@@ -342,6 +343,9 @@ PyObject *ToNumPyArray(MCData *self, int npyObjectType, const char *MCDataStr)
 SWIGINTERN PyObject *MEDCoupling_DataArrayInt_toNumPyArray(MEDCoupling::DataArrayInt *self);
 SWIGINTERN PyObject *MEDCoupling_DataArrayDouble_toNumPyArray(MEDCoupling::DataArrayDouble *self);
 
+#endif
+
+#ifdef WITH_SCIPY
 PyObject *ToCSRMatrix(const std::vector<std::map<int,double> >& m, int nbCols)
 {
   int nbRows((int)m.size());
@@ -384,6 +388,8 @@ PyObject *ToCSRMatrix(const std::vector<std::map<int,double> >& m, int nbCols)
   return ret;
 }
 
+#endif
+
 static PyObject *convertDataArrayChar(MEDCoupling::DataArrayChar *dac, int owner)
 {
   PyObject *ret=0;
index b221c8b5a46fa58eea439ef5187e4f99f06320be..e8059978d8705cd270ebcaa59c5dd646381641d3 100644 (file)
@@ -1064,14 +1064,14 @@ void MEDPARTITIONERTest::verifyMetisOrScotchMedpartitionerOnSmallSizeForMesh(std
   int nbcells=0;
   for (std::size_t i = 0; i < cellMeshes.size(); i++)
     nbcells+=cellMeshes[i]->getNumberOfCells();
-  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), nbcells);
+  CPPUNIT_ASSERT_EQUAL((int)cellMesh->getNumberOfCells(), nbcells);
 
   std::vector<MEDCoupling::MEDCouplingUMesh*>faceMeshes=collection.getFaceMesh();
   CPPUNIT_ASSERT_EQUAL(5, (int) faceMeshes.size());
   int nbfaces=0;
   for (std::size_t i=0; i < faceMeshes.size(); i++)
     nbfaces+=faceMeshes[i]->getNumberOfCells();
-  CPPUNIT_ASSERT_EQUAL(faceMesh->getNumberOfCells(), nbfaces);
+  CPPUNIT_ASSERT_EQUAL((int)faceMesh->getNumberOfCells(), nbfaces);
 
   //merge split meshes and test equality
   cmd=execName+" --ndomains=1 --split-method="+MetisOrScotch;  //on same proc
@@ -1183,7 +1183,7 @@ void MEDPARTITIONERTest::verifyMetisOrScotchMedpartitionerOnSmallSizeForFieldOnC
   MCAuto<MEDCouplingFieldDouble> field2=ReadFieldCell(refusedName.c_str(),refusedCellMesh->getName().c_str(),0,"VectorFieldOnCells",0,1);
 
   int nbcells=corr[1]->getNumberOfTuples();
-  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), nbcells);
+  CPPUNIT_ASSERT_EQUAL((int)cellMesh->getNumberOfCells(), nbcells);
   //use corr to test equality of field
   DataArrayDouble* f1=field1->getArray();
   DataArrayDouble* f2=field2->getArray();
@@ -1270,7 +1270,7 @@ void MEDPARTITIONERTest::verifyMetisOrScotchMedpartitionerOnSmallSizeForFieldOnG
   MCAuto<MEDCouplingFieldDouble> field2=ReadField(ON_GAUSS_NE,refusedName.c_str(),refusedCellMesh->getName().c_str(),0,"MyFieldOnGaussNE",5,6);
 
   int nbcells=corr[1]->getNumberOfTuples();
-  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), nbcells);
+  CPPUNIT_ASSERT_EQUAL((int)cellMesh->getNumberOfCells(), nbcells);
   //use corr to test equality of field
   DataArrayDouble* f1=field1->getArray();
   DataArrayDouble* f2=field2->getArray();