| 3897 | |
| 3898 | |
| 3899 | static int |
| 3900 | _set_full_args_out(int nout, PyObject *out_obj, ufunc_full_args *full_args) |
| 3901 | { |
| 3902 | if (PyTuple_CheckExact(out_obj)) { |
| 3903 | if (PyTuple_GET_SIZE(out_obj) != nout) { |
| 3904 | PyErr_SetString(PyExc_ValueError, |
| 3905 | "The 'out' tuple must have exactly " |
| 3906 | "one entry per ufunc output"); |
| 3907 | return -1; |
| 3908 | } |
| 3909 | if (tuple_all_none(out_obj)) { |
| 3910 | return 0; |
| 3911 | } |
| 3912 | else { |
| 3913 | Py_INCREF(out_obj); |
| 3914 | full_args->out = out_obj; |
| 3915 | } |
| 3916 | } |
| 3917 | else if (nout == 1) { |
| 3918 | if (out_obj == Py_None) { |
| 3919 | return 0; |
| 3920 | } |
| 3921 | /* Can be an array if it only has one output */ |
| 3922 | full_args->out = PyTuple_Pack(1, out_obj); |
| 3923 | if (full_args->out == NULL) { |
| 3924 | return -1; |
| 3925 | } |
| 3926 | } |
| 3927 | else { |
| 3928 | PyErr_SetString(PyExc_TypeError, |
| 3929 | nout > 1 ? "'out' must be a tuple of arrays" : |
| 3930 | "'out' must be an array or a tuple with " |
| 3931 | "a single array"); |
| 3932 | return -1; |
| 3933 | } |
| 3934 | return 0; |
| 3935 | } |
| 3936 | |
| 3937 | |
| 3938 | /* |
no test coverage detected