Skip to content

switch to simplified ufunc/binop interaction/opt-out - #4

Merged
charris merged 4 commits into
charris:enable-numpy_ufuncfrom
mhvk:array_ufunc_opt_out
Mar 12, 2017
Merged

charris merged 4 commits into
charris:enable-numpy_ufuncfrom
mhvk:array_ufunc_opt_out

Conversation

@mhvk

@mhvk mhvk commented Mar 12, 2017

Copy link
Copy Markdown

(see main PR for comments)

njsmith and others added 4 commits March 12, 2017 11:31
…attr_string.h

This is an ugly kluge, but until we merge multiarray.so and umath.so
moving stuff into private/*.h serves as a reasonable workaround.
For some reason, np.generic.__pow__ felt the need to reimplement
Python's full binop dispatch logic. The code has been there since the
beginning of (git) history, isn't required to pass any tests, and
AFAICT doesn't actually do anything interesting. I suspect it was just
split apart from the (much more trivial) implementation of all the
other np.generic binop methods because nb_power has a slightly
different signature than all the others (it takes an extra argument,
which we ignore, but still has to be accepted and passed as
appropriate), and then got forgotten when the other implementations
were simplified long ago.

This commit throws away all that code and makes gentype_power a
2-liner, just like all the other gentype_@name@ methods.
As per the discussion at numpygh-5844, and in particular
   numpy#5844 (comment)
this commit switches binop dispatch to mostly defer to ufuncs, except
in some specific cases elaborated in a long comment in number.c.

The basic strategy is to define a single piece of C code that knows
how to handle forward binop overrides, and we put it into
private/binop_override.h so that it can be accessed by both the array
code in multiarray.so and the scalar code in umath.so.
In previous versions, one could force ndarray binops to defer by
setting a high __array_priority__.  With __array_ufunc__ this gets
ignored, and this commit ensures it is still possible to avoid
using the standard python language feature that setting something
to None means it is not implemented. In consequence, inside a
ufunc, if __array_ufunc__ is None, it will be treated as if it
had returned NotImplemented (leading to a TypeError if no other
object had a functioning __array_ufunc__ override).
@charris
charris merged this pull request into charris:enable-numpy_ufunc Mar 12, 2017
@charris

charris commented Mar 12, 2017

Copy link
Copy Markdown
Owner

OK, I'm just going to merge this so that it gets tested and can be reviewed with all the rest of the changes.

@mhvk
mhvk deleted the array_ufunc_opt_out branch March 15, 2017 16:52
charris pushed a commit that referenced this pull request Nov 21, 2021
commit 9c833bed5879d77e625556260690c349de18b433
Author: Thomas Li <[email protected]>
Date:   Wed Nov 17 16:21:27 2021 -0800

    Add Windows config to GHA

    update script [wheel build]

    typo [wheel build]

    fix typo? [wheel build]

    fix linux builds? [wheel build]

    typo [wheel build]

    add license and pin to windows 2016

    skip tests [wheel build]

    pin to windows 2019 instead [wheel build]

    try to find out the error on windows [wheel build]

    maybe fix? [wheel build]

    maybe fix? [wheel build]

    fix? [wheel build]

    cleanup [wheel build]

    Add Windows config to GHA

    update script [wheel build]

    typo [wheel build]

    fix typo? [wheel build]

    fix linux builds? [wheel build]

    typo [wheel build]

    add license and pin to windows 2016

    skip tests [wheel build]

    pin to windows 2019 instead [wheel build]

    try to find out the error on windows [wheel build]

    maybe fix? [wheel build]

    maybe fix? [wheel build]

    fix? [wheel build]

    cleanup [wheel build]

    Update LICENSE_win32.txt

    Update LICENSE_win32.txt

    Add Windows config to GHA

    update script [wheel build]

    typo [wheel build]

    fix typo? [wheel build]

    fix linux builds? [wheel build]

    typo [wheel build]

    add license and pin to windows 2016

    skip tests [wheel build]

    pin to windows 2019 instead [wheel build]

    try to find out the error on windows [wheel build]

    maybe fix? [wheel build]

    maybe fix? [wheel build]

    fix? [wheel build]

    cleanup [wheel build]

    Update LICENSE_win32.txt

    Update LICENSE_win32.txt

    Update cibw_test_command.sh

commit 4bd12df
Author: Thomas Li <[email protected]>
Date:   Mon Nov 15 17:28:47 2021 -0800

    # This is a combination of 14 commits.
    # This is the 1st commit message:

    Add Windows config to GHA
    # This is the commit message #2:

    update script [wheel build]
    # This is the commit message #3:

    typo [wheel build]
    # This is the commit message #4:

    fix typo? [wheel build]
    # This is the commit message #5:

    fix linux builds? [wheel build]
    # This is the commit message #6:

    typo [wheel build]
    # This is the commit message #7:

    add license and pin to windows 2016
    # This is the commit message #8:

    skip tests [wheel build]
    # This is the commit message #9:

    pin to windows 2019 instead [wheel build]
    # This is the commit message #10:

    try to find out the error on windows [wheel build]
    # This is the commit message #11:

    maybe fix? [wheel build]
    # This is the commit message #12:

    maybe fix? [wheel build]
    # This is the commit message #13:

    fix? [wheel build]
    # This is the commit message #14:

    cleanup [wheel build]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants