-
Notifications
You must be signed in to change notification settings - Fork 11
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
allow uneven length #65
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65 +/- ##
==========================================
- Coverage 92.53% 91.28% -1.25%
==========================================
Files 5 5
Lines 442 459 +17
==========================================
+ Hits 409 419 +10
- Misses 33 40 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Thanks @zhaotingchen! This has been something that I've considered for quite a while. I think this all looks good, but I definitely want some tests and docs in there. We'll want to do a full-circle test (produce box with power spectrum, compute power spectrum from box, make sure it matches the input). You could use pytest.mark.parametrize
to check a bunch of different shapes.
|
||
def k(self): | ||
"""The entire grid of wavenumber magitudes.""" | ||
return _magnitude_grid(self.kvec, self.dim) | ||
kval = np.meshgrid(*self.kvec, indexing="ij") | ||
kmode = np.sqrt(np.sum([k_i**2 for k_i in kval], axis=0)) |
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 could just be np.sqrt(np.sum(kval**2, axis=0))
for i in range(self.dim): | ||
kvec_i = self.fftbackend.fftfreq(self.N[i], d=self.dx[i], b=self.fourier_b) | ||
kvec_arr += (kvec_i,) |
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 could probably just be a comprehension:
kvecarr = tuple(self.fftbackend.fftfreq(self.N[i], d=self.dx[i], b=self.fourier_b) for i in range(self.dim))
self.boxlength = boxlength | ||
if isinstance(self.boxlength, numbers.Number): | ||
self.boxlength = [self.boxlength] * self.dim |
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.
Somewhere in the __init__
there should be some checks that the length of N
and boxsize
are the same, and equivalent to dim
.
|
||
@property | ||
def r(self): | ||
"""The radial position of every point in the grid.""" | ||
return _magnitude_grid(self.x, self.dim) | ||
xval = np.meshgrid(*self.x, indexing="ij") |
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.
we could probably instead just update _magnitude_grid
to be able to handle a tuple of arrays
fix #64
Still need doc updates and tests to cover uneven length cases