Skip to content

Commit

Permalink
Merge pull request #15271 from seberg/splitup-faster-argparsing
Browse files Browse the repository at this point in the history
ENH: Optimize and cleanup ufunc calls and ufunc CheckOverrides
  • Loading branch information
charris committed Mar 24, 2021
2 parents badbf70 + bebf5c8 commit 74e5bff
Show file tree
Hide file tree
Showing 9 changed files with 929 additions and 1,177 deletions.
31 changes: 31 additions & 0 deletions doc/release/upcoming_changes/15271.compatibility.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Error type changes in universal functions
-----------------------------------------
The universal functions may now raise different errors
on invalid input in some cases.
The main changes should be that a ``RuntimeError`` was
replaced with a more fitting ``TypeError``.
When multiple errors were present in the same call,
NumPy may now raise a different one.


``__array_ufunc__`` argument validation
---------------------------------------
NumPy will now partially validate arguments before calling
``__array_ufunc__``. Previously, it was possible to pass
on invalid arguments (such as a non-existing keyword
argument) when dispatch was known to occur.


``__array_ufunc__`` and additional positional arguments
-------------------------------------------------------
Previously, all positionally passed arguments were checked for
``__array_ufunc__`` support. In the case of ``reduce``,
``accumulate``, and ``reduceat`` all arguments may be passed by
position. This means that when they were passed by
position, they could previously have been asked to handle
the ufunc call via ``__array_ufunc__``.
Since this depended on the way the arguments were passed
(by position or by keyword), NumPy will now only dispatch
on the input and output array.
For example, NumPy will never dispatch on the ``where`` array
in a reduction such as ``np.add.reduce``.
4 changes: 4 additions & 0 deletions numpy/core/include/numpy/ufuncobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ typedef struct _tagPyUFuncObject {
* but this was never implemented. (This is also why the above
* selector is called the "legacy" selector.)
*/
#if PY_VERSION_HEX >= 0x03080000
vectorcallfunc vectorcall;
#else
void *reserved2;
#endif
/*
* A function which returns a masked inner loop for the ufunc.
*/
Expand Down

0 comments on commit 74e5bff

Please sign in to comment.