Skip to content
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

Revisit need for our own ufunc type resolver #105

Open
mhvk opened this issue Mar 28, 2023 · 1 comment
Open

Revisit need for our own ufunc type resolver #105

mhvk opened this issue Mar 28, 2023 · 1 comment

Comments

@mhvk
Copy link
Contributor

mhvk commented Mar 28, 2023

Currently, we override the standard numpy type resolver, because, as seen in this extract:

pyerfa/erfa/ufunc.c.templ

Lines 535 to 545 in e33ee55

* We provide our own type resolver, since the default one,
* PyUFunc_DefaultTypeResolver from
* numpy/core/src/umath/ufunc_type_resolution.c, has problems:
* 1. It only looks for userloops if any of the operands have a user
* type, which does not work if the inputs are normal and no explicit
* output is given (see https://github.com/numpy/numpy/issues/11109).
* 2. It only allows "safe" casting of inputs, which annoyingly prevents
* passing in a python int for int32 input.
* The resolver below solves both, and speeds up the process by
* explicitly assuming that a ufunc has only one function built in,
* either a regular one or a userloop (for structured dtype).

However, as noted in numpy/numpy#11109 (comment), things should now work for us. So, this is a reminder to try removing our work-around.

@mhvk
Copy link
Contributor Author

mhvk commented Mar 28, 2023

A quick test shows that one cannot just remove the resolver (numpy 1.24.2 or numpy 1.25.dev). Likely, as noted in the comment, we'd need to define our own promotors.

See numpy/numpy#11109 (comment)

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

No branches or pull requests

1 participant