-
Notifications
You must be signed in to change notification settings - Fork 45
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
isospectrum debugging / refactoring #89
Conversation
Sounds good, I'll try clean up the PR. |
Codecov Report
@@ Coverage Diff @@
## master #89 +/- ##
==========================================
+ Coverage 97.08% 97.47% +0.38%
==========================================
Files 2 2
Lines 755 752 -3
Branches 130 118 -12
==========================================
Hits 733 733
+ Misses 12 10 -2
+ Partials 10 9 -1
Continue to review full report at Codecov.
|
I'd like to propose renaming
My preference goes to the second option. |
Things to do:
|
I'm ok with this, but let's do a deprecation cycle. We will keep the old function names for now but just have them call the new functions and issue a I personally prefer isotropic_power_spectrum and isotropic_cross_spectrum because they are more explicit. |
Sounds good. I won't be able to tackle before approx 1 week unfortunately. |
this PR has been moving along and is close to be reviewed. Before then, do I need to address codecov failings? I am not sure what I'm supposed to do with these. |
I was about to say that this was ready for review but got an issue with python 2.7 test. ping @rabernat |
I'm in favor of ending support for py27... |
If we're going to keep support py27 as for now, one way would be to check the python version on the run with |
Let's just drop py2.7. We don't have enough users for a deprecation cycle. @apatlpo - just remove the py2.7 environment from the travis config and let's see if the tests go green. |
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.
This is looking great. Thanks for all your work @apatlpo!
xrft/tests/test_xrft.py
Outdated
@@ -652,13 +652,68 @@ def _synthetic_field(N, dL, amp, s): | |||
theta = np.fft.ifft2(np.fft.ifftshift(F_theta)) | |||
return np.real(theta) | |||
|
|||
def _synthetic_field_xr(N, dL, amp, s, |
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.
You don't need to use private functions in tests. It's not part of public API anyway. Rename to synthetic_field
.
There should also probably be a fixture.
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'm not sure what a fixture precisely is, but I am under the impression that because I am calling the method multiple times with different input parameters it may not be suited to this case. Correct?
xrft/tests/test_xrft.py
Outdated
spacing_tol = 1e-3 | ||
nfactor = 4 | ||
ps = xrft.power_spectrum(da, spacing_tol, dim=dims) | ||
ps_iso = xrft.isotropize(ps, fftdim, nfactor=nfactor) |
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.
This test is not actually checking anything. It's just verifying that the function does not raise an error.
Here's an idea: rather than calling power_spectrum
, can you just make up a synthetic spectrum with a known isotropic spectrum, and then verify that isotropize
does the right thing? You will want some assert
statements in there somewhere.
xrft/xrft.py
Outdated
Deprecated function. See isotropic_cross_spectrum doc | ||
""" | ||
import warnings | ||
msg = "Deprecated. Use isotropic_cross_spectrum instead" |
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.
What about "This function has been renamed and will disappear in the future. Please use isotropic_cross_spectrum instead"
Travis goes through but not codecov. |
Codecov is telling us that the test coverage has gone slightly down. The coverage tells you which percentage of the code base is covered by tests, so this means there are some new code paths that are not tested. You can use the codecov site to figure out where exactly these are. If you can add some tests This may seem like a pain, but it's very useful to have high test coverage like we have now, and we want to try to maintain this. You can check coverage locally while developing by running this command: Line 47 in 41cf806
This should be a relatively simple fix, but it turns out to be complicated or annoying, we can just accept the drop in coverage and move on. Thanks for your perseverance with this PR. |
thanks for the explanation Ryan. I had to add tests for the methods that will be soon deprecated. |
Ah ok, I understand. In that case, please add a Then we are done. |
done |
Fantastic! Thanks so much for your persistence! We really appreciate having you as a contributor to xrft. |
This PR attemps to fix several issues related to isospectrum computations:
breaks with dask arrays (dask bincount does not handle mixed types arguments)
breaks with extra dimensions
See gist for illustration of failures
I also propose a modest refactoring which consists in adding an isotropize methods that average spectra or crossspectra azimuthaly.
This method is called by isotropic_powerspectrum and isotropic_crossspectrum
There are still some improvements that could be made:
If you believe this PR is worth anything, let me know, I can finetune, even though weeks to come are going to be busy with Ocean Sciences and all.
cheers