Skip to content

ufunc calls with mixed args and upcast types#951

Merged
bors[bot] merged 3 commits into
hgrecco:masterfrom
keewis:fix-is_upcast_type
Dec 26, 2019
Merged

ufunc calls with mixed args and upcast types#951
bors[bot] merged 3 commits into
hgrecco:masterfrom
keewis:fix-is_upcast_type

Conversation

@keewis

@keewis keewis commented Dec 23, 2019

Copy link
Copy Markdown
Contributor

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

@jthielen jthielen left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread pint/compat.py
@keewis

keewis commented Dec 23, 2019

Copy link
Copy Markdown
Contributor Author

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

@hgrecco

hgrecco commented Dec 26, 2019

Copy link
Copy Markdown
Owner

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

I agree, merging

@hgrecco

hgrecco commented Dec 26, 2019

Copy link
Copy Markdown
Owner

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

bors Bot commented Dec 26, 2019

Copy link
Copy Markdown
Contributor

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