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

Introduce a value range check on the numpy level #43

Merged
merged 6 commits into from
Jun 30, 2022

Conversation

jbusecke
Copy link
Contributor

I have implemented a checking function on the numpy level that can be turned on/off. This function checks the 'shrunken' arguments for nans and values that are out of the allowed range. This should completely eliminate the need for propagating errors from the fortran level (#4, #11), since we are now catching eveything that would lead to a STOP in fortran at the python level.

Copy link
Collaborator

@paigem paigem 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 great @jbusecke!! Thanks!! Just a couple very minor comments/questions then I think we are ready to merge! 😄

range_data = data
# check the absolute value if specified in range
if range[2]:
range_data = abs(range_data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need these lines to check for absolute value? Couldn't we just use a valid range of [-50,50] for both u_zu and v_zu that would achieve the same result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, totally. And it will make the code wasier to read!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. This is much nicer. Thanks for the suggestion.

zt=2,
zu=10,
niter=6,
input_range_check=True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want this to be True by default? If this adds any extra time, then maybe we default to False?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thinking was that we should have the user friendly option by default. Think of a novice user that just naively puts in sst in C. Id much rather have them get a helpful error message.

BUT maybe we want to explicity say that the check costs performance in that warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a warning that gets raise each time the range check is performed.

@jbusecke
Copy link
Contributor Author

@paigem if you think those changes are sufficient, I think we can merge this after the tests pass.

@jbusecke
Copy link
Contributor Author

I think once this is done, we could release either 0.3.0 (since this has quite a few major new features) or 0.2.6.
Maybe @paigem wants to do the release?

@paigem
Copy link
Collaborator

paigem commented Jun 30, 2022

Ooh I don't even know where to start in making a release! But maybe that would be a good learning opportunity.

Also, the CI tests didn't all pass. Looks like the test_range_check_nan() is raising an AssertionError from line 80 for each variable. @jbusecke

Co-authored-by: Paige Martin <paigemar@umich.edu>
@jbusecke
Copy link
Contributor Author

Ooh I don't even know where to start in making a release! But maybe that would be a good learning opportunity.

That would be the point 😜. Also its pretty easy (if things dont break haha).

@jbusecke
Copy link
Contributor Author

Thanks for fixing the CI!

@jbusecke jbusecke merged commit 8a802fc into xgcm:main Jun 30, 2022
This was referenced Jun 30, 2022
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.

Explicitly handle the input argument ranges from Aerobulk
2 participants