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

[bugfix] WeightedVariance is broken in a couple of ways in yt-4.0 #2348

Merged
merged 2 commits into from
Oct 28, 2019

Conversation

jzuhone
Copy link
Contributor

@jzuhone jzuhone commented Oct 22, 2019

In the yt-4.0 branch, the WeightedVariance derived quantity (and thus the std method of data containers which is downstream from it) has a couple of bugs.

  1. If one runs into a case where some chunks have a weight which sums to zero, the code returns floating-point zeros to be used in the final variance calculation. However, the chunks with data are not dimensionless in general, and so when one attempts to add everything together you get a IterableUnitCoercionError. This PR fixes that by dropping the units during the calculating and assigning them at the end.

  2. I also noticed after fixing 1. that the answers given were not the same as if one had simply computed the weighted variance by hand using NumPy on the data object's field. I tracked this second error down to commit 191056c.

Which was just a mix-up in the reformatting of the line.

I'll see what I can do about improving test coverage for this.

@ngoldbaum
Copy link
Member

Ugh, sorry for the pain my typo back in March caused you. Thank you for tracking this down and fixing it.

@jzuhone
Copy link
Contributor Author

jzuhone commented Oct 22, 2019

@ngoldbaum no big deal, someone will catch something I did next, I am sure.

Copy link
Member

@munkm munkm left a comment

Choose a reason for hiding this comment

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

This looks good to me. I think the answer test failure is from cartopy and I'm trying to track down the cause.

@munkm
Copy link
Member

munkm commented Oct 25, 2019

Ok @jzuhone the fix for the Travis tests should be on the 4.0 branch now. If you merge or rebase those tests should pass. 🙂

@jzuhone
Copy link
Contributor Author

jzuhone commented Oct 28, 2019

I'm satisfied with the test coverage here, actually. This is ok to merge whenever.

@ngoldbaum ngoldbaum merged commit 947ebdc into yt-project:yt-4.0 Oct 28, 2019
@jzuhone jzuhone deleted the variance_fix branch November 22, 2019 19:02
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