-
Notifications
You must be signed in to change notification settings - Fork 10
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
ctf_freq shape mismatch #40
ctf_freq shape mismatch #40
Conversation
……98, and should be one point less. the spacing is fine, so I just get up to the right index. this is passing: for n_pixels in range(2,2000,2): assert transfer.ctf_freqs(n_pixels,dim=2)[0].shape[0] == n_pixels
I'm not sure if the main branch is clean... or if the testing environment may not work for other reasons outside of the bug. If the main branch is not clean you can see the tests pass here geoffwoollard#1 |
Codecov Report
@@ Coverage Diff @@
## master #40 +/- ##
==========================================
+ Coverage 97.15% 97.34% +0.20%
==========================================
Files 5 6 +1
Lines 140 150 +10
==========================================
+ Hits 136 146 +10
Misses 4 4
Continue to review full report at Codecov.
|
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.
Looks good to me!
@@ -36,12 +41,14 @@ def ctf_freqs(n_pixels, psize=1.0, dim=2): | |||
""" | |||
if dim == 1: | |||
freq_pix_1d = np.arange(0, 0.5, 1 / n_pixels) | |||
freq_1d = freq_pix_1d * psize | |||
freq_pix_1d_safe = freq_pix_1d[: n_pixels // 2] |
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 looks like it's solving a different error: that line was forgotten initially, correct?
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.
Normally freq_pix_1d was the right size of n_pixels // 2
, but then for size 98 it gets this extra element because of how np.array treats things (closed vs open intervals I suppose). So I just enforce that it doesn't have this extra point. The intervals are all good, before it just sometimes had an extra end point.
return freq_1d | ||
|
||
# assert d == 2 | ||
freq_pix_1d = np.arange(-0.5, 0.5, 1 / n_pixels) | ||
x, y = np.meshgrid(freq_pix_1d, freq_pix_1d) | ||
freq_pix_1d_safe = freq_pix_1d[:n_pixels] |
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.
Good catch @geoffwoollard ! I'm still not 100% sure I follow but it seems to do the trick!
There was a bug that the test was catching that only came up for n_pixels=98, because of how the end point is calculated using np.arange. I've fixed and updated with documentation