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

BUG: fix incorrect output unit for np.prod with an axis argument #537

Merged
merged 4 commits into from
Dec 16, 2024

Conversation

kyleaoman
Copy link
Contributor

Closes #536

When an axis keyword is passed to np.prod, the power that the dimensions should be raised to are not the size of the array but the ratio of the sizes of the input array and returned array (it's always this, but without the kwarg the size of the returned array is 1).

@kyleaoman
Copy link
Contributor Author

pre-commit.ci autofix

Copy link
Member

@neutrinoceros neutrinoceros 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 noticing and patching this !
The same problem is present with np.nanprod, and your patch also fixes it, however that's mostly due to an implementation detail in numpy that we don't control so it should be tested too.
Otherwise, LGTM

@neutrinoceros neutrinoceros changed the title Prod bugfix BUG: fix incorrect output unit for np.prod with an axis argument Dec 16, 2024
@neutrinoceros neutrinoceros added the bug Something isn't working label Dec 16, 2024
@neutrinoceros neutrinoceros added this to the 3.0.4 milestone Dec 16, 2024
@kyleaoman
Copy link
Contributor Author

@neutrinoceros done - just parametrized the new test across prod and nanprod.

@neutrinoceros
Copy link
Member

Thanks ! let's get this one in !

@neutrinoceros neutrinoceros merged commit db4f940 into yt-project:main Dec 16, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect units when using np.prod with an axis kwarg
2 participants