From: Anthony Geay Date: Wed, 31 May 2017 06:53:02 +0000 (+0200) Subject: Numpy optionnal dependancies + getNumberOfCells porting X-Git-Tag: V8_4_0a1~25^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5eae23234bd4841ace5096e61a8126b8c0eabe49;p=tools%2Fmedcoupling.git Numpy optionnal dependancies + getNumberOfCells porting --- diff --git a/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx b/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx index c22b758dc..bc3d93680 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx +++ b/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx @@ -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 struct PyCallBackDataArraySt { @@ -327,6 +329,7 @@ PyTypeObject PyCallBackDataArrayDouble_RefType = { PyObject_GC_Del, /*tp_free*/ }; +#ifdef WITH_NUMPY template struct NPYTraits { @@ -347,5 +350,6 @@ struct NPYTraits static PyTypeObject *NPYFunc; static PyObject *Array_SWIGTYPE; }; +#endif #endif diff --git a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i index 31c881f06..8f596420d 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i @@ -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 @@ -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 >& m, int nbCols) { int nbRows((int)m.size()); @@ -384,6 +388,8 @@ PyObject *ToCSRMatrix(const std::vector >& m, int nbCols) return ret; } +#endif + static PyObject *convertDataArrayChar(MEDCoupling::DataArrayChar *dac, int owner) { PyObject *ret=0; diff --git a/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx b/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx index b221c8b5a..e8059978d 100644 --- a/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx +++ b/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx @@ -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::vectorfaceMeshes=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 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 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();