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

ufunc calls with mixed args and upcast types #951

Merged
merged 3 commits into from
Dec 26, 2019

Conversation

keewis
Copy link
Contributor

@keewis keewis commented Dec 23, 2019

This fixes an issue with calling ufuncs with mixed args including upcast types: Calling a bivariate ufunc like np.maximum(da, 0 * ureg.m) resulted in pint trying to work with upcast types because __array_ufunc__ works with type objects while is_upcast_type checked object instances.

  • Executed black -t py36 . && isort -rc . && flake8 with no errors
  • The change is fully covered by automated unit tests

Copy link
Contributor

@jthielen jthielen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this!

I have one comment below and a question: would you want to add tests for this now, or wait for the ones outlined in #845?

pint/compat.py Show resolved Hide resolved
@keewis
Copy link
Contributor Author

keewis commented Dec 23, 2019

I think the tests should go to a PR for #845.

@hgrecco
Copy link
Owner

hgrecco commented Dec 26, 2019

I think the tests should go to a PR for #845.

I agree, merging

@hgrecco
Copy link
Owner

hgrecco commented Dec 26, 2019

bors r+

bors bot added a commit that referenced this pull request Dec 26, 2019
951: ufunc calls with mixed args and upcast types r=hgrecco a=keewis

This fixes an issue with calling ufuncs with mixed args including upcast types: Calling a bivariate ufunc like `np.maximum(da, 0 * ureg.m)` resulted in `pint` trying to work with upcast types because `__array_ufunc__` works with type objects while `is_upcast_type` checked object instances.

- [x] Executed ``black -t py36 . && isort -rc . && flake8`` with no errors
- [ ] The change is fully covered by automated unit tests


Co-authored-by: Keewis <keewis@posteo.de>
@bors
Copy link
Contributor

bors bot commented Dec 26, 2019

Build succeeded

@bors bors bot merged commit 6f1e41e into hgrecco:master Dec 26, 2019
@keewis keewis deleted the fix-is_upcast_type branch December 27, 2019 00:05
jthielen added a commit to jthielen/pint that referenced this pull request Dec 27, 2019
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