diff options
-rw-r--r-- | numpy/add_newdocs.py | 154 | ||||
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 18 | ||||
-rw-r--r-- | numpy/core/src/umath/umathmodule.c.src | 8 |
3 files changed, 164 insertions, 16 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 0d7f89830..4cd2984cc 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -4048,6 +4048,160 @@ add_newdoc('numpy.core', 'ufunc', ############################################################################## # +# ufunc attributes +# +############################################################################## + +add_newdoc('numpy.core', 'ufunc', ('identity', + """ + The identity value. + + Data attribute containing the identity element for the ufunc, if it has one. + If it does not, the attribute value is None. + + Examples + -------- + >>> np.add.identity + 0 + >>> np.multiply.identity + 1 + >>> np.power.identity + 1 + >>> print np.exp.identity + None + """)) + +add_newdoc('numpy.core', 'ufunc', ('nargs', + """ + The number of arguments. + + Data attribute containing the number of arguments the ufunc takes, including + optional ones. + + Notes + ----- + Typically this value will be one more than what you might expect because all + ufuncs take the optional "out" argument. + + Examples + -------- + >>> np.add.nargs + 3 + >>> np.multiply.nargs + 3 + >>> np.power.nargs + 3 + >>> np.exp.nargs + 2 + """)) + +add_newdoc('numpy.core', 'ufunc', ('nin', + """ + The number of inputs. + + Data attribute containing the number of arguments the ufunc treats as input. + + Examples + -------- + >>> np.add.nin + 2 + >>> np.multiply.nin + 2 + >>> np.power.nin + 2 + >>> np.exp.nin + 1 + """)) + +add_newdoc('numpy.core', 'ufunc', ('nout', + """ + The number of outputs. + + Data attribute containing the number of arguments the ufunc treats as output. + + Notes + ----- + Since all ufuncs can take output arguments, this will always be (at least) 1. + + Examples + -------- + >>> np.add.nout + 1 + >>> np.multiply.nout + 1 + >>> np.power.nout + 1 + >>> np.exp.nout + 1 + + """)) + +add_newdoc('numpy.core', 'ufunc', ('ntypes', + """ + The number of types. + + The number of numerical NumPy types - of which there are 18 total - on which + the ufunc can operate. + + See Also + -------- + numpy.ufunc.types + + Examples + -------- + >>> np.add.ntypes + 18 + >>> np.multiply.ntypes + 18 + >>> np.power.ntypes + 17 + >>> np.exp.ntypes + 7 + >>> np.remainder.ntypes + 14 + + """)) + +add_newdoc('numpy.core', 'ufunc', ('types', + """ + Returns a list with types grouped input->output. + + Data attribute listing the data-type "Domain-Range" groupings the ufunc can + deliver. The data-types are given using the character codes. + + See Also + -------- + numpy.ufunc.ntypes + + Examples + -------- + >>> np.add.types + ['??->?', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', + 'LL->L', 'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'FF->F', 'DD->D', + 'GG->G', 'OO->O'] + + >>> np.multiply.types + ['??->?', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', + 'LL->L', 'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'FF->F', 'DD->D', + 'GG->G', 'OO->O'] + + >>> np.power.types + ['bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L', + 'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'FF->F', 'DD->D', 'GG->G', + 'OO->O'] + + >>> np.exp.types + ['f->f', 'd->d', 'g->g', 'F->F', 'D->D', 'G->G', 'O->O'] + + >>> np.remainder.types + ['bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L', + 'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'OO->O'] + + """)) + + +############################################################################## +# # ufunc methods # ############################################################################## diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 9a54ae400..df4fb1c8a 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -4290,31 +4290,31 @@ ufunc_get_signature(PyUFuncObject *self) static PyGetSetDef ufunc_getset[] = { {"__doc__", (getter)ufunc_get_doc, - NULL, "documentation string", NULL}, + NULL, NULL, NULL}, {"nin", (getter)ufunc_get_nin, - NULL, "number of inputs", NULL}, + NULL, NULL, NULL}, {"nout", (getter)ufunc_get_nout, - NULL, "number of outputs", NULL}, + NULL, NULL, NULL}, {"nargs", (getter)ufunc_get_nargs, - NULL, "number of arguments", NULL}, + NULL, NULL, NULL}, {"ntypes", (getter)ufunc_get_ntypes, - NULL, "number of types", NULL}, + NULL, NULL, NULL}, {"types", (getter)ufunc_get_types, - NULL, "return a list with types grouped input->output", NULL}, + NULL, NULL, NULL}, {"__name__", (getter)ufunc_get_name, - NULL, "function name", NULL}, + NULL, NULL, NULL}, {"identity", (getter)ufunc_get_identity, - NULL, "identity value", NULL}, + NULL, NULL, NULL}, {"signature", (getter)ufunc_get_signature, - NULL, "signature", NULL}, + NULL, NULL, NULL}, {NULL, NULL, NULL, NULL, NULL}, /* Sentinel */ }; diff --git a/numpy/core/src/umath/umathmodule.c.src b/numpy/core/src/umath/umathmodule.c.src index 4a51b5828..1a5c14756 100644 --- a/numpy/core/src/umath/umathmodule.c.src +++ b/numpy/core/src/umath/umathmodule.c.src @@ -43,12 +43,6 @@ static PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om}; -static char -doc_frompyfunc[] = "frompyfunc(func, nin, nout) take an arbitrary python\n" \ - "function that takes nin objects as input and returns\n" \ - "nout objects and return a universal function (ufunc).\n" \ - "This ufunc always returns PyObject arrays\n"; - static PyObject * ufunc_frompyfunc(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *NPY_UNUSED(kwds)) { /* Keywords are ignored for now */ @@ -240,7 +234,7 @@ InitOtherOperators(PyObject *dictionary) { static struct PyMethodDef methods[] = { {"frompyfunc", (PyCFunction) ufunc_frompyfunc, - METH_VARARGS | METH_KEYWORDS, doc_frompyfunc}, + METH_VARARGS | METH_KEYWORDS, NULL}, {"seterrobj", (PyCFunction) ufunc_seterr, METH_VARARGS, NULL}, {"geterrobj", (PyCFunction) ufunc_geterr, |