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

rely on numpy's version of nanprod and nansum #6873

Merged
merged 4 commits into from
Aug 9, 2022

Conversation

keewis
Copy link
Collaborator

@keewis keewis commented Aug 3, 2022

At the moment, nanprod and nansum will replace any nan values with 1 for nanprod or 0 for nansum. For pint, inserting dimensionless values into quantities is explicitly not allowed, so our version of nanprod cannot be used on pint quantities (0 is a exception so nansum does work).

I'm proposing to rely on numpy's version for that, which would allow pint to customize the behavior.

@keewis keewis mentioned this pull request Aug 3, 2022
18 tasks
@dcherian
Copy link
Contributor

dcherian commented Aug 3, 2022

Hmm... This will require bumping minimum pint version to avoid breakage: >

???
E   TypeError: no implementation found for 'numpy.nanprod' on types that implement __array_function__: [<class 'pint.quantity.build_quantity_class.<locals>.Quantity'>]

EDIT: I guess this didn't work earlier so we just need to xfail on old pint.

Copy link
Contributor

@dcherian dcherian left a comment

Choose a reason for hiding this comment

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

Thanks @keewis.

It looked like we could remove _replace_nan so I pushed a commit to do that.

@dcherian dcherian merged commit 8417f49 into pydata:main Aug 9, 2022
@keewis keewis deleted the nanprod-with-units branch August 9, 2022 17:31
@keewis keewis mentioned this pull request Sep 22, 2022
1 task
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.

2 participants