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

Adding default n_steps and adding ndim #20

Merged
merged 9 commits into from
Feb 9, 2021

Conversation

iangrooms
Copy link
Member

This PR does a few things:

  1. Add in a default for n_steps that depends on the coarsening factor (filter_scale/dx_min)
  2. Add an option to switch between 1d and 2d grids ndmin
  3. Change the meaning of filter_scale in both filter shapes, so that it always corresponds to a boxcar of width filter_scale

@rabernat
Copy link
Contributor

rabernat commented Feb 6, 2021

Thanks for getting this started @iangrooms! Let me know when you're ready for some feedback.

The "pre-commit" part of the checks does code linting (checking that the code formatting conforms to standards, etc.) You can set it up locally following the contributor guide and have it run automatically every time you commit. It will give hints on how to satisfy its checks.

@iangrooms
Copy link
Member Author

@rabernat this pull request should be ready. Not sure why it says it's failing the pre-commit, since it passes on my machine. Also, all tests currently pass.

Copy link
Contributor

@rabernat rabernat left a comment

Choose a reason for hiding this comment

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

This is great @iangrooms! Congrats on successfully jumping through all of the hoops (tests, pre-commit, etc.)

I don't understand the pre-commit failure either, but for now I think we can safely ignore it.

I have a few tiny suggestions for docstring formatting and a question about how to handle the ndim parameter.

gcm_filters/filter.py Show resolved Hide resolved
gcm_filters/filter.py Outdated Show resolved Hide resolved
gcm_filters/filter.py Outdated Show resolved Hide resolved
iangrooms and others added 2 commits February 8, 2021 15:52
Co-authored-by: Ryan Abernathey <[email protected]>
Co-authored-by: Ryan Abernathey <[email protected]>
@codecov-io
Copy link

codecov-io commented Feb 8, 2021

Codecov Report

Merging #20 (8777072) into master (2dded95) will decrease coverage by 1.69%.
The diff coverage is 72.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #20      +/-   ##
==========================================
- Coverage   97.64%   95.94%   -1.70%     
==========================================
  Files           7        7              
  Lines         212      222      +10     
==========================================
+ Hits          207      213       +6     
- Misses          5        9       +4     
Flag Coverage Δ
unittests 95.94% <72.22%> (-1.70%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tests/test_filter.py 100.00% <ø> (ø)
gcm_filters/filter.py 95.28% <70.58%> (-3.68%) ⬇️
gcm_filters/kernels.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2dded95...8777072. Read the comment docs.

@rabernat
Copy link
Contributor

rabernat commented Feb 9, 2021

Ok great!

Do you see anything in the tutorial that needs to be updated because of the API change? If not, I think this is ready to merge.

@iangrooms
Copy link
Member Author

Do you see anything in the tutorial that needs to be updated because of the API change? If not, I think this is ready to merge.

I checked the tutorial, and there shouldn't be any changes. I also added an error if the user tries to use ndim>2 with the default n_steps. So I think it should be ready

@rabernat
Copy link
Contributor

rabernat commented Feb 9, 2021

Ok great, I'll merge. Thanks a lot @iangrooms!

For reference, the coverage report is referring to the fact that some parts of the new if / else block for ndim are not covered by tests (red lines here): https://codecov.io/gh/ocean-eddy-cpt/gcm-filters/pull/20/src/gcm_filters/filter.py?before=gcm_filters/filter.py#L70...82

To keep test coverage high, technically we should add test scenarios for each of these different options, including the errors. However, that feels a little too strict for the early stage this package is at, so we will let it slide for now. I'll put a reminder in #18 about this.

@rabernat rabernat marked this pull request as ready for review February 9, 2021 20:37
@rabernat
Copy link
Contributor

rabernat commented Feb 9, 2021

@jbusecke it won't let me merge because of the pre-commit failure. Can you look at this and try to figure out what's going on? Ian says the pre-commit passes locally, but the workflow is still failing. If the pre-commit is going to be flaky like this, I feel like we should disable it as a required check.

@jbusecke
Copy link
Collaborator

jbusecke commented Feb 9, 2021

Let me look into this.

@jbusecke
Copy link
Collaborator

jbusecke commented Feb 9, 2021

I can reproduce the error locally on my machine. @iangrooms could you confirm which conda environment you used? Did you run pre-commit run --all-files from the root directory?

Another thing I noticed is that you started this PR from your master branch. Not sure if that is causing this trouble though. In general it is recommended to check out a new branch with git checkout -b <new_cool_branchname>.

@rabernat rabernat merged commit 73baa9e into ocean-eddy-cpt:master Feb 9, 2021
@jbusecke
Copy link
Collaborator

jbusecke commented Feb 9, 2021

Oh I see this was solved. What was the culprit in the end?

@iangrooms
Copy link
Member Author

pre-commit changes files, including ones that I wasn't working on (kernels.py). So when I ran pre-commit it would fail, then I'd make some changes, then it would pass. But I didn't commit the changes that pre-commit made to files that I wasn't working on. That's why pre-commit passed locally but failed on the server; once I committed the changes to kernels.py (not made by me), it fixed the problem on the server.

@rabernat
Copy link
Contributor

once I committed the changes to kernels.py (not made by me), it fixed the problem on the server.

Yet strangely, kernels.py does not show up in the files changed tab of this PR. 🧐

I'm still learning about pre-commit myself, so it's useful to get this feedback.

@jbusecke
Copy link
Collaborator

Thanks for the feedback @iangrooms. That is quite strange, actually. It should not let you push the commit if there are problems with the committed files. Or at least that is how I understand it.

For what its worth, I personally always do a manual pre-commit run pre-commit run --all-files, then another git add -u before the commit I want to push, but that is maybe not the smoothest way of doing it.

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.

4 participants