Skip to content

Conversation

zhaotingchen
Copy link

fix #64

Still need doc updates and tests to cover uneven length cases

Copy link

codecov bot commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 92.50000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.28%. Comparing base (b739a54) to head (9af9af1).
Report is 2 commits behind head on main.

Files Patch % Lines
src/powerbox/powerbox.py 92.50% 3 Missing ⚠️
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     
Flag Coverage Δ
unittests 91.28% <92.50%> (-1.25%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@steven-murray steven-murray left a 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.

"""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))
Copy link
Owner

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))

Comment on lines +186 to +188
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,)
Copy link
Owner

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.N = [self.N] * self.dim
self.boxlength = boxlength
if isinstance(self.boxlength, numbers.Number):
self.boxlength = [self.boxlength] * self.dim
Copy link
Owner

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.

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")
Copy link
Owner

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

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.

Unequal lengths and grid size for box

2 participants