我正在CentOS 7上使用Anaconda Spyder 3.3.6(Python3.7)
static PyObject * squeezeSurfaces(PyObject* self, PyObject* args)
{
PyArrayObject *matin, *matout;
double ***cin, ***cout, dfactor;
int i,j,k,n,m,l, dims[3], ifactor;
// Parse tuples separately since args will differ between C fcns
if (!PyArg_ParseTuple(args, "O!id",
&PyArray_Type, &matin, &ifactor, &dfactor)) return NULL;
if (NULL == matin) return NULL;
// Check that object input is 'double' type and a matrix
// Not needed if python wrapper function checks before call to this routine
if (not_doublematrix(matin)) return NULL;
// Get the dimensions of the input
n=dims[0]=matin->dimensions[0];
m=dims[1]=matin->dimensions[1];
l=dims[2]=matin->dimensions[2];
// Make a new double matrix of same dims
matout=(PyArrayObject *) PyArray_SimpleNew(3,dims,NPY_DOUBLE);
Py_INCREF(matin);
return PyArray_Return(matin);
}
使用以下Python代码
import surfaceModules as sm
import numpy as NP
x=NP.zeros(27)
for i in range(0,27): x[i]=i
x=x.reshape(3,3,3)
jfac=2
xfac=1.5
y=sm.squeezeSurfaces(x, jfac, xfac)
我收到以下信息
__main__:10: DeprecationWarning: PyArray_FromDims: use PyArray_SimpleNew.
__main__:10: DeprecationWarning: PyArray_FromDimsAndDataAndDescr: use PyArray_NewFromDescr.
所以我用PyArray\u SimpleNew替换了PyArray\u FromDims
这导致了
ValueError: array is too big; `arr.size * arr.dtype.itemsize` is larger than the maximum possible size.
使用相同的Python代码。它是一个3立方数组,所以总共应该只有27个元素。请注意,这发生在Spyder和Jupyter笔记本上
目前没有回答
相关问题 更多 >
编程相关推荐