10000 WIP: Alternative ufunc signature expansion for flexible dimensions by mhvk · Pull Request #11165 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

WIP: Alternative ufunc signature expansion for flexible dimensions #11165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
add tests for new signatures
  • Loading branch information
mattip committed May 18, 2018
commit dbbeb5868a263379eb8ae5fbfe123e8e215d1488
17 changes: 12 additions & 5 deletions numpy/core/src/umath/_umath_tests.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,10 @@ addUfuncs(PyObject *dictionary) {
static PyObject *
UMath_Tests_test_signature(PyObject *NPY_UNUSED(dummy), PyObject *args)
{
int nin, nout;
int nin, nout, i;
PyObject *signature, *sig_str;
PyObject *f;
PyUFuncObject *f;
PyObject *core_num_dims;
int core_enabled;

if (!PyArg_ParseTuple(args, "iiO", &nin, &nout, &signature)) return NULL;
Expand All @@ -378,17 +379,23 @@ UMath_Tests_test_signature(PyObject *NPY_UNUSED(dummy), PyObject *args)
return NULL;
}

f = PyUFunc_FromFuncAndDataAndSignature(NULL, NULL, NULL,
f = (PyUFuncObject*)PyUFunc_FromFuncAndDataAndSignature(NULL, NULL, NULL,
0, nin, nout, PyUFunc_None, "no name",
"doc:none",
1, PyString_AS_STRING(sig_str));
if (sig_str != signature) {
Py_DECREF(sig_str);
}
if (f == NULL) return NULL;
core_enabled = ((PyUFuncObject*)f)->core_enabled;
core_enabled = f->core_enabled;
core_num_dims = PyTuple_New(f->nargs);
if (core_num_dims == NULL) return NULL;
for (i=0; i<f->nargs; i++) {
PyObject * val = PyLong_FromLong(f->core_num_dims[i]);
PyTuple_SET_ITEM(core_num_dims, i, val);
}
Py_DECREF(f);
return Py_BuildValue("i", core_enabled);
return Py_BuildValue("iO", core_enabled, core_num_dims);
}

static PyMethodDef UMath_TestsMethods[] = {
Expand Down
0