-
Notifications
You must be signed in to change notification settings - Fork 280
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
fix: unbounded variable in shear calculation #2850
fix: unbounded variable in shear calculation #2850
Conversation
6b5fcdf
to
791c9ee
Compare
791c9ee
to
3e0d8fe
Compare
Ok, I'll do my best to review this soon. Would you mind updating the PR description to list (maybe a bulleted list) of all of the bugs that this PR addresses so it's easier to summarize it when we do a release? 🙂 |
done ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is nice and I like the specific handling addressed in this PR. I think it would be nice to add more tests for this functionality so we know we're catching things as we expect them. I'll approve this and you can add tests here or open an issue to add more later.
I'll add tests now and you guys can merge when they pass :) |
Ah I just noticed that the _shear_mach definition is almost an exact duplicate of this one and has the same issues. |
Looks like it's not covered. For the time being, I'll just reapply the same fix there, but I think there's room for a larger code deduplication in this file, that I will attempt to do later. |
for reference, this dataset would be perfect to test some of the edge cases here: |
The travis failure looks like another random fail like the one @matthewturk fixed this week. Reported #2861 |
…n't necesseraly tell us how many velocity components there are (e.g. AMRVAC can run 2D simulations with 3 velocity components)
32f9d14
to
048f0e9
Compare
PR Summary
Working on #2848 I opened Pandora's box and found several bugs in shear computation.
This fixes them.
Namely, the function used dimensionality checks where really, what we want is to know wether velocity component are available. The difference is important for AMRVAC datasets, for instance, where one can run a model in a 2D box, but all velocity components are still present.
In particular, if called with 1D data, the intermediate variable
f
would end up unbounded (which is how I discovered this).So in summary:
ValueError
) if called with data that only has 1 velocity component, instead of a defactoUnboundedLocalError
The reason these changes shouldn't break anything is that the one time this internal function is called is inside a try block that currently catches everything, so introducing early exception raising here is not a problem.
PR Checklist
black --check yt/
isort . --check --diff
flake8 yt/
flynt yt/ --fail-on-change --dry-run -e yt/extern