From 8b321cc5b49329eca081cee3016d1f620b2e246e Mon Sep 17 00:00:00 2001 From: Greg Landrum Date: Fri, 21 Nov 2008 05:55:08 +0000 Subject: [PATCH] fix 2318431: deprecation warnings from numpy --- .../Wrap/rdMetricMatrixCalc.cpp | 31 +++++++------- Code/DistGeom/Wrap/DistGeom.cpp | 17 +++----- .../DistGeomHelpers/Wrap/rdDistGeom.cpp | 12 +++--- .../DistGeomHelpers/Wrap/rdDistGeom.h | 15 ------- Code/GraphMol/MolAlign/Wrap/rdMolAlign.cpp | 10 ++--- .../MolTransforms/Wrap/rdMolTransforms.cpp | 15 +++---- Code/GraphMol/Wrap/MolOps.cpp | 20 ++++----- Code/GraphMol/Wrap/rough_test.py | 41 +++++++++++++++++-- Code/ML/Cluster/Murtagh/Clustering.cpp | 23 +++++------ .../InfoTheory/Wrap/BitCorrMatGenerator.cpp | 10 ++--- Code/ML/InfoTheory/Wrap/InfoBitRanker.cpp | 10 ++--- Code/Numerics/Alignment/Wrap/rdAlignment.cpp | 8 ++-- 12 files changed, 111 insertions(+), 101 deletions(-) delete mode 100644 Code/GraphMol/DistGeomHelpers/Wrap/rdDistGeom.h diff --git a/Code/DataManip/MetricMatrixCalc/Wrap/rdMetricMatrixCalc.cpp b/Code/DataManip/MetricMatrixCalc/Wrap/rdMetricMatrixCalc.cpp index 892516543..40e1e6b9f 100755 --- a/Code/DataManip/MetricMatrixCalc/Wrap/rdMetricMatrixCalc.cpp +++ b/Code/DataManip/MetricMatrixCalc/Wrap/rdMetricMatrixCalc.cpp @@ -1,13 +1,13 @@ // $Id$ // -// Copyright (C) 2003-2006 Rational Discovery LLC +// Copyright (C) 2003-2008 Greg Landrum and Rational Discovery LLC // // @@ All Rights Reserved @@ // #define PY_ARRAY_UNIQUE_SYMBOL rdmetric_array_API #include #include -#include "numpy/oldnumeric.h" +#include "numpy/arrayobject.h" #include #include @@ -57,23 +57,22 @@ namespace RDDataManip { int i; CHECK_INVARIANT((nrows > 0) && (ncols > 0), ""); - int dMatLen = nrows*(nrows-1)/2; + npy_intp dMatLen = nrows*(nrows-1)/2; // now that we have the dimensions declare the distance matrix which is always a // 1D double array - distRes = (PyArrayObject *)PyArray_FromDims(1, &dMatLen, PyArray_DOUBLE); + distRes = (PyArrayObject *)PyArray_SimpleNew(1, &dMatLen, NPY_DOUBLE); // grab a pointer to the data in the array so that we can directly put values in there - // and avoid copying (as I understand it PyArray_FromDimsAndData will do it here for us - // because python will never free the malloced memory this way) + // and avoid copying : double *dMat = (double *)distRes->data; - // if we have double array PyArrayObject *copy; copy = (PyArrayObject *)PyArray_ContiguousFromObject(descMatObj, ((PyArrayObject *)descMatObj)->descr->type_num, 2,2); - if (((PyArrayObject *)descMatObj)->descr->type_num == PyArray_DOUBLE) { + // if we have double array + if (((PyArrayObject *)descMatObj)->descr->type_num == NPY_DOUBLE) { double *desc = (double *)copy->data; // REVIEW: create an adaptor object to hold a double * and support @@ -96,7 +95,7 @@ namespace RDDataManip { } // if we have a float array - else if (((PyArrayObject *)descMatObj)->descr->type_num == PyArray_FLOAT) { + else if (((PyArrayObject *)descMatObj)->descr->type_num == NPY_FLOAT) { float* desc = (float *)copy->data; float **desc2D = new float*[nrows]; for (i = 0; i < nrows; i++) { @@ -111,7 +110,7 @@ namespace RDDataManip { } // if we have an interger array - else if (((PyArrayObject *)descMatObj)->descr->type_num == PyArray_INT) { + else if (((PyArrayObject *)descMatObj)->descr->type_num == NPY_INT) { int *desc = (int *)copy->data; int **desc2D = new int*[nrows]; for (i = 0; i < nrows; i++) { @@ -138,8 +137,8 @@ namespace RDDataManip { unsigned int nrows = python::extract(descripMat.attr("__len__")()); CHECK_INVARIANT(nrows > 0, "Empty list passed in"); - int dMatLen = nrows*(nrows-1)/2; - distRes = (PyArrayObject *)PyArray_FromDims(1, &dMatLen, PyArray_DOUBLE); + npy_intp dMatLen = nrows*(nrows-1)/2; + distRes = (PyArrayObject *)PyArray_SimpleNew(1, &dMatLen, NPY_DOUBLE); double *dMat = (double *)distRes->data; // assume that we a have a list of list of values (that can be extracted to double) @@ -177,8 +176,8 @@ namespace RDDataManip { throw_value_error("GetTanimotoDistMat can only take a sequence of ExplicitBitVects or SparseBitvects"); } - int dMatLen = nrows*(nrows-1)/2; - PyArrayObject *simRes = (PyArrayObject *)PyArray_FromDims(1, &dMatLen, PyArray_DOUBLE); + npy_intp dMatLen = nrows*(nrows-1)/2; + PyArrayObject *simRes = (PyArrayObject *)PyArray_SimpleNew(1, &dMatLen, NPY_DOUBLE); double *sMat = (double *)simRes->data; if (ebvWorks.check()) { @@ -210,8 +209,8 @@ namespace RDDataManip { throw_value_error("GetTanimotoDistMat can only take a sequence of ExplicitBitVects or SparseBitvects"); } - int dMatLen = nrows*(nrows-1)/2; - PyArrayObject *simRes = (PyArrayObject *)PyArray_FromDims(1, &dMatLen, PyArray_DOUBLE); + npy_intp dMatLen = nrows*(nrows-1)/2; + PyArrayObject *simRes = (PyArrayObject *)PyArray_SimpleNew(1, &dMatLen, NPY_DOUBLE); double *sMat = (double *)simRes->data; if (ebvWorks.check()) { diff --git a/Code/DistGeom/Wrap/DistGeom.cpp b/Code/DistGeom/Wrap/DistGeom.cpp index 70b45f37c..d97d0ea9a 100644 --- a/Code/DistGeom/Wrap/DistGeom.cpp +++ b/Code/DistGeom/Wrap/DistGeom.cpp @@ -1,6 +1,6 @@ // $Id$ // -// Copyright (C) 2004-2006 Rational Discovery LLC +// Copyright (C) 2004-2008 Greg Landrum and Rational Discovery LLC // // @@ All Rights Reserved @@ // @@ -8,7 +8,7 @@ #include #define PY_ARRAY_UNIQUE_SYMBOL DistGeom_array_API -#include "numpy/oldnumeric.h" +#include "numpy/arrayobject.h" #include #include @@ -28,8 +28,6 @@ namespace python = boost::python; namespace RDKit { - - bool doTriangleSmoothing(python::object boundsMatArg){ PyObject *boundsMatObj = boundsMatArg.ptr(); if(!PyArray_Check(boundsMatObj)) @@ -59,7 +57,7 @@ namespace RDKit { memcpy(static_cast(inData), static_cast(cData), dSize*sizeof(double)); - return (PyObject *) res; + return res; } PyObject *embedBoundsMatrix(python::object boundsMatArg,int maxIters=10, @@ -147,24 +145,21 @@ namespace RDKit { // ---- ---- ---- ---- ---- ---- ---- ---- ---- // construct the results matrix: - int dims[2]; + npy_intp dims[2]; dims[0] = nrows; dims[1] = 3; - PyArrayObject *res = (PyArrayObject *)PyArray_FromDims(2,dims,PyArray_DOUBLE); + PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(2,dims,NPY_DOUBLE); double *resData=reinterpret_cast(res->data); for(unsigned int i=0;i +#define PY_ARRAY_UNIQUE_SYMBOL rdDistGeom_array_API +#include "numpy/arrayobject.h" #include #include @@ -72,20 +74,20 @@ namespace RDKit { PyObject *getMolBoundsMatrix(ROMol &mol, bool set15bounds=true, bool scaleVDW=false) { - int dims[2]; unsigned int nats = mol.getNumAtoms(); + npy_intp dims[2]; dims[0] = nats; dims[1] = nats; DistGeom::BoundsMatPtr mat(new DistGeom::BoundsMatrix(nats)); DGeomHelpers::initBoundsMat(mat); DGeomHelpers::setTopolBounds(mol,mat, set15bounds, scaleVDW); - PyArrayObject *res = (PyArrayObject *)PyArray_FromDims(2,dims,PyArray_DOUBLE); + PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(2,dims,NPY_DOUBLE); memcpy(static_cast(res->data), static_cast(mat->getData()), nats*nats*sizeof(double)); - return (PyObject *) res; + return PyArray_Return(res); } } diff --git a/Code/GraphMol/DistGeomHelpers/Wrap/rdDistGeom.h b/Code/GraphMol/DistGeomHelpers/Wrap/rdDistGeom.h deleted file mode 100644 index efa79170e..000000000 --- a/Code/GraphMol/DistGeomHelpers/Wrap/rdDistGeom.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (C) 2004-2006 Rational Discovery LLC -// -// @@ All Rights Reserved @@ -// - -#ifndef _RDDISTGEOM_H_13122004_1315_ -#define _RDDISTGEOM_H_13122004_1315_ - -#include - -#define PY_ARRAY_UNIQUE_SYMBOL rdDistGeom_array_API -#include "numpy/oldnumeric.h" - -#endif diff --git a/Code/GraphMol/MolAlign/Wrap/rdMolAlign.cpp b/Code/GraphMol/MolAlign/Wrap/rdMolAlign.cpp index 68340a112..5f14e081d 100644 --- a/Code/GraphMol/MolAlign/Wrap/rdMolAlign.cpp +++ b/Code/GraphMol/MolAlign/Wrap/rdMolAlign.cpp @@ -1,13 +1,13 @@ // $Id$ // -// Copyright (C) 2004-2006 Rational Discovery LLC +// Copyright (C) 2004-2008 Greg Landrum and Rational Discovery LLC // // @@ All Rights Reserved @@ // #define PY_ARRAY_UNIQUE_SYMBOL rdmolalign_array_API #include #include -#include "numpy/oldnumeric.h" +#include "numpy/arrayobject.h" #include #include @@ -105,10 +105,10 @@ namespace RDKit { RDGeom::Transform3D trans; double rmsd = MolAlign::getAlignmentTransform(prbMol, refMol, trans, prbCid, refCid, aMap, wtsVec, reflect, maxIters); - int dims[2]; + npy_intp dims[2]; dims[0] = 4; dims[1] = 4; - PyArrayObject *res = (PyArrayObject *)PyArray_FromDims(2,dims,PyArray_DOUBLE); + PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(2,dims,NPY_DOUBLE); double *resData=reinterpret_cast(res->data); unsigned int j, itab; const double *tdata = trans.getData(); @@ -128,7 +128,7 @@ namespace RDKit { PyObject *resTup = PyTuple_New(2); PyObject *rmsdItem = PyFloat_FromDouble(rmsd); PyTuple_SetItem(resTup,0,rmsdItem); - PyTuple_SetItem(resTup,1,reinterpret_cast(res)); + PyTuple_SetItem(resTup,1,PyArray_Return(res)); return resTup; } diff --git a/Code/GraphMol/MolTransforms/Wrap/rdMolTransforms.cpp b/Code/GraphMol/MolTransforms/Wrap/rdMolTransforms.cpp index 418b16802..eb6ea4297 100644 --- a/Code/GraphMol/MolTransforms/Wrap/rdMolTransforms.cpp +++ b/Code/GraphMol/MolTransforms/Wrap/rdMolTransforms.cpp @@ -1,12 +1,12 @@ // $Id$ // -// Copyright (C) 2005-2006 Rational Discovery LLC +// Copyright (C) 2005-2008 Greg Landrum and Rational Discovery LLC // // @@ All Rights Reserved @@ // #define PY_ARRAY_UNIQUE_SYMBOL rdmoltransforms_array_API #include -#include "numpy/oldnumeric.h" +#include "numpy/arrayobject.h" #include #include #include @@ -20,22 +20,17 @@ namespace RDKit { PyObject *computeCanonTrans(const Conformer &conf, const RDGeom::Point3D *center=0, bool normalizeCovar=false, bool ignoreHs=true) { RDGeom::Transform3D *trans; - //if (center == NULL) { - // trans = MolTransforms::computeCanonicalTransform(conf, 0, - // normalizeCovar); - //} else { trans = MolTransforms::computeCanonicalTransform(conf, center, normalizeCovar, ignoreHs); - //} - int dims[2]; + npy_intp dims[2]; dims[0] = 4; dims[1] = 4; - PyArrayObject *res = (PyArrayObject *)PyArray_FromDims(2,dims,PyArray_DOUBLE); + PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(2,dims,NPY_DOUBLE); double *resData=reinterpret_cast(res->data); const double *tdata = trans->getData(); memcpy(static_cast(resData), static_cast(tdata), 4*4*sizeof(double)); delete trans; - return reinterpret_cast(res); + return PyArray_Return(res); } void transConformer(Conformer &conf, python::object trans) { diff --git a/Code/GraphMol/Wrap/MolOps.cpp b/Code/GraphMol/Wrap/MolOps.cpp index 73ea87cc8..39f93b0c4 100755 --- a/Code/GraphMol/Wrap/MolOps.cpp +++ b/Code/GraphMol/Wrap/MolOps.cpp @@ -7,7 +7,7 @@ #define NO_IMPORT_ARRAY #include "rdmolops.h" #include -#include +#include #include #include @@ -77,27 +77,27 @@ namespace RDKit{ PyObject *getDistanceMatrix(ROMol &mol, bool useBO=false, bool useAtomWts=false,bool force=false, const char *prefix=0) { - int dims[2]; int nats = mol.getNumAtoms(); + npy_intp dims[2]; dims[0] = nats; dims[1] = nats; double *distMat; distMat = MolOps::getDistanceMat(mol, useBO, useAtomWts,force,prefix); - PyArrayObject *res = (PyArrayObject *)PyArray_FromDims(2,dims,PyArray_DOUBLE); + PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(2,dims,NPY_DOUBLE); memcpy(static_cast(res->data), static_cast(distMat),nats*nats*sizeof(double)); - return (PyObject *) res; + return PyArray_Return(res); } PyObject *getAdjacencyMatrix(ROMol &mol, bool useBO=false, int emptyVal=0,bool force=false, const char *prefix=0) { - int dims[2]; int nats = mol.getNumAtoms(); + npy_intp dims[2]; dims[0] = nats; dims[1] = nats; @@ -106,13 +106,13 @@ namespace RDKit{ PyArrayObject *res; if(useBO){ // if we're using valence, the results matrix is made up of doubles - res = (PyArrayObject *)PyArray_FromDims(2,dims, - PyArray_DOUBLE); + res = (PyArrayObject *)PyArray_SimpleNew(2,dims, + NPY_DOUBLE); memcpy(static_cast(res->data), static_cast(tmpMat),nats*nats*sizeof(double)); } else { - res = (PyArrayObject *)PyArray_FromDims(2,dims, - PyArray_INT); + res = (PyArrayObject *)PyArray_SimpleNew(2,dims, + NPY_INT); int *data = (int *)res->data; for(int i=0;i self.failUnless(len(fs)==1) self.failUnless(fs[0].GetNumAtoms()==3) - + def test53Matrices(self) : + """ test adjacency and distance matrices + + """ + m = Chem.MolFromSmiles('CC=C') + d = Chem.GetDistanceMatrix(m,0) + self.failUnless(feq(d[0,1],1.0)) + self.failUnless(feq(d[0,2],2.0)) + self.failUnless(feq(d[1,0],1.0)) + self.failUnless(feq(d[2,0],2.0)) + a = Chem.GetAdjacencyMatrix(m,0) + self.failUnless(a[0,1]==1) + self.failUnless(a[0,2]==0) + self.failUnless(a[1,2]==1) + self.failUnless(a[1,0]==1) + self.failUnless(a[2,0]==0) + + m = Chem.MolFromSmiles('C1CC1') + d = Chem.GetDistanceMatrix(m,0) + self.failUnless(feq(d[0,1],1.0)) + self.failUnless(feq(d[0,2],1.0)) + a = Chem.GetAdjacencyMatrix(m,0) + self.failUnless(a[0,1]==1) + self.failUnless(a[0,2]==1) + self.failUnless(a[1,2]==1) + + m = Chem.MolFromSmiles('CC.C') + d = Chem.GetDistanceMatrix(m,0) + self.failUnless(feq(d[0,1],1.0)) + self.failUnless(d[0,2]>1000) + self.failUnless(d[1,2]>1000) + a = Chem.GetAdjacencyMatrix(m,0) + self.failUnless(a[0,1]==1) + self.failUnless(a[0,2]==0) + self.failUnless(a[1,2]==0) + + + diff --git a/Code/ML/Cluster/Murtagh/Clustering.cpp b/Code/ML/Cluster/Murtagh/Clustering.cpp index ac3eddfdf..c7edfb107 100755 --- a/Code/ML/Cluster/Murtagh/Clustering.cpp +++ b/Code/ML/Cluster/Murtagh/Clustering.cpp @@ -1,5 +1,6 @@ +// $Id$ // -// Copyright (C) 2002,2003 Greg Landrum and Rational Discovery LLC +// Copyright (C) 2002-2008 Greg Landrum and Rational Discovery LLC // All Rights Reserved // #ifdef WIN32 @@ -7,8 +8,7 @@ #endif #define PYTH_FILE_WITH_INIT #include "Clustering.h" -#include - +#include #ifdef WIN32 BOOL APIENTRY DllMain( HANDLE hModule, @@ -79,7 +79,7 @@ Clustering_MurtaghCluster(PyObject *self,PyObject *args) real *crit; PyObject *res; PyObject *tmp; - int dims[2]; + npy_intp dims[2]; if(!PyArg_ParseTuple(args,"Oiii",&data,&nPts,&sz,&option)) return NULL; @@ -94,18 +94,17 @@ Clustering_MurtaghCluster(PyObject *self,PyObject *args) dims[0] = nPts; res = PyTuple_New(3); - // // NOTE: these operations maintain pointers to the respective arrays, // that's why it's ok that we do not free them in this function, // Python will take care of it for us. // - tmp = PyArray_FromDimsAndData(1,dims,PyArray_LONG,(char *)ia); + tmp = PyArray_SimpleNewFromData(1,dims,NPY_LONG,(void *)ia); PyTuple_SetItem(res,0,(PyObject *)tmp); - tmp = PyArray_FromDimsAndData(1,dims,PyArray_LONG,(char *)ib); + tmp = PyArray_SimpleNewFromData(1,dims,NPY_LONG,(void *)ib); PyTuple_SetItem(res,1,(PyObject *)tmp); - tmp = PyArray_FromDimsAndData(1,dims,PyArray_DOUBLE,(char *)crit); + tmp = PyArray_SimpleNewFromData(1,dims,NPY_DOUBLE,(void *)crit); PyTuple_SetItem(res,2,(PyObject *)tmp); Py_DECREF(dataContig); @@ -133,7 +132,7 @@ Clustering_MurtaghDistCluster(PyObject *self,PyObject *args) real *crit; PyObject *res=PyTuple_New(3); PyObject *tmp; - int dims[] = {1}; + npy_intp dims[] = {1}; if(!PyArg_ParseTuple(args,"Oii",&data,&nPts,&option)) return NULL; @@ -151,13 +150,13 @@ Clustering_MurtaghDistCluster(PyObject *self,PyObject *args) // that's why it's ok that we do not free them in this function, // Python will take care of it for us. // - tmp = PyArray_FromDimsAndData(1,dims,PyArray_LONG,(char *)ia); + tmp = PyArray_SimpleNewFromData(1,dims,NPY_LONG,(void *)ia); PyTuple_SetItem(res,0,tmp); - tmp = PyArray_FromDimsAndData(1,dims,PyArray_LONG,(char *)ib); + tmp = PyArray_SimpleNewFromData(1,dims,NPY_LONG,(void *)ib); PyTuple_SetItem(res,1,tmp); - tmp = PyArray_FromDimsAndData(1,dims,PyArray_DOUBLE,(char *)crit); + tmp = PyArray_SimpleNewFromData(1,dims,NPY_DOUBLE,(void *)crit); PyTuple_SetItem(res,2,tmp); Py_DECREF(dataContig); diff --git a/Code/ML/InfoTheory/Wrap/BitCorrMatGenerator.cpp b/Code/ML/InfoTheory/Wrap/BitCorrMatGenerator.cpp index 9114d979e..dc0f9ada8 100755 --- a/Code/ML/InfoTheory/Wrap/BitCorrMatGenerator.cpp +++ b/Code/ML/InfoTheory/Wrap/BitCorrMatGenerator.cpp @@ -1,6 +1,6 @@ // $Id$ // -// Copyright (C) 2003-2007 Greg Landrum and Rational Discovery LLC +// Copyright (C) 2003-2008 Greg Landrum and Rational Discovery LLC // All Rights Reserved // @@ -8,7 +8,7 @@ #define NO_IMPORT_ARRAY #include #define PY_ARRAY_UNIQUE_SYMBOL rdinfotheory_array_API -#include "numpy/oldnumeric.h" +#include "numpy/arrayobject.h" #include #include @@ -22,11 +22,11 @@ namespace RDInfoTheory { PyObject *getCorrMatrix(BitCorrMatGenerator *cmGen) { double *dres = cmGen->getCorrMat(); unsigned int nb = cmGen->getCorrBitList().size(); - int dim = nb*(nb-1)/2; - PyArrayObject *res = (PyArrayObject *)PyArray_FromDims(1,&dim,PyArray_DOUBLE); + npy_intp dim = nb*(nb-1)/2; + PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(1,&dim,NPY_DOUBLE); memcpy(static_cast(res->data), static_cast(dres), dim*sizeof(double)); - return (PyObject *) res; + return PyArray_Return(res); } void setBitList(BitCorrMatGenerator *cmGen, python::object bitList) { diff --git a/Code/ML/InfoTheory/Wrap/InfoBitRanker.cpp b/Code/ML/InfoTheory/Wrap/InfoBitRanker.cpp index 06b0553a1..e208232ae 100755 --- a/Code/ML/InfoTheory/Wrap/InfoBitRanker.cpp +++ b/Code/ML/InfoTheory/Wrap/InfoBitRanker.cpp @@ -1,13 +1,13 @@ // $Id$ // -// Copyright (C) 2003-2007 Greg Landrum and Rational Discovery LLC +// Copyright (C) 2003-2008 Greg Landrum and Rational Discovery LLC // All Rights Reserved // #define NO_IMPORT_ARRAY #include #define PY_ARRAY_UNIQUE_SYMBOL rdinfotheory_array_API -#include "numpy/oldnumeric.h" +#include "numpy/arrayobject.h" #include @@ -21,13 +21,13 @@ namespace RDInfoTheory { PyObject *getTopNbits(InfoBitRanker *ranker, int num){// int ignoreNoClass=-1) { double *dres = ranker->getTopN(num); - int dims[2]; + npy_intp dims[2]; dims[0] = num; dims[1] = ranker->getNumClasses() + 2; - PyArrayObject *res = (PyArrayObject *)PyArray_FromDims(2,dims,PyArray_DOUBLE); + PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(2,dims,NPY_DOUBLE); memcpy(static_cast(res->data), static_cast(dres), dims[0]*dims[1]*sizeof(double)); - return (PyObject *) res; + return PyArray_Return(res); } void AccumulateVotes(InfoBitRanker *ranker, python::object bitVect, int label) { diff --git a/Code/Numerics/Alignment/Wrap/rdAlignment.cpp b/Code/Numerics/Alignment/Wrap/rdAlignment.cpp index cab1f03de..86c6fd4b7 100644 --- a/Code/Numerics/Alignment/Wrap/rdAlignment.cpp +++ b/Code/Numerics/Alignment/Wrap/rdAlignment.cpp @@ -7,7 +7,7 @@ #define PY_ARRAY_UNIQUE_SYMBOL rdalignment_array_API #include #include -#include "numpy/oldnumeric.h" +#include "numpy/arrayobject.h" #include #include @@ -123,10 +123,10 @@ namespace RDNumeric { RDGeom::Transform3D trans; double ssd = AlignPoints(refPts, probePts, trans, wtsVec, reflect, maxIterations); - int dims[2]; + npy_intp dims[2]; dims[0] = 4; dims[1] = 4; - PyArrayObject *res = (PyArrayObject *)PyArray_FromDims(2,dims,PyArray_DOUBLE); + PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(2,dims,NPY_DOUBLE); double *resData=reinterpret_cast(res->data); const double *tdata = trans.getData(); for(unsigned int i=0; i < trans.numRows(); ++i){ @@ -147,7 +147,7 @@ namespace RDNumeric { PyObject *resTup = PyTuple_New(2); PyObject *ssdItem = PyFloat_FromDouble(ssd); PyTuple_SetItem(resTup,0,ssdItem); - PyTuple_SetItem(resTup,1,reinterpret_cast(res)); + PyTuple_SetItem(resTup,1,PyArray_Return(res)); return resTup; } }