Commits

Antonio Cuni  committed aa6043f

(partly) implement PyArray_Return

  • Participants
  • Parent commits fd3e670

Comments (0)

Files changed (2)

     Py_RETURN_NONE;
 }
 
+static PyObject*
+fakenumpy__test_Return() {
+    double data[4] = {1, 2, 3, 4};
+    npy_intp dims[2] = {2, 2};
+    PyArrayObject* array = (PyArrayObject*)PyArray_SimpleNewFromData(2, dims, PyArray_FLOAT64, data);
+    //
+    py_assert(PyArray_Return(array) == array);
+    Py_RETURN_NONE;
+}
+
+
 static PyMethodDef fakenumpy_methods[] = {
     {"_frombuffer_2_2", fakenumpy__frombuffer_2_2, METH_VARARGS, "..."},
     {"_test_DIMS", fakenumpy__test_DIMS, METH_NOARGS, "..."},
+    {"_test_Return", fakenumpy__test_Return, METH_NOARGS, "..."},
     {NULL}  /* Sentinel */
 };
 
 #define PyArray_NDIM(array) (array->ndims)
 #define PyArray_DIMS(array) (array->dims)
 
+// XXX: we don't properly implement PyArray_Return if ndims is ==0, because we
+// never needed it so far
+#define PyArray_Return(array) (assert(array->ndims > 0), array)
+
 #endif