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

Filter func tests #424

Merged
merged 7 commits into from
Oct 9, 2024
Merged

Filter func tests #424

merged 7 commits into from
Oct 9, 2024

Conversation

daviesje
Copy link
Contributor

@daviesje daviesje commented Sep 3, 2024

This PR combines the three filtering functions present in v4-prep, and makes some tests for the filter functions which:

  • ensures that each filter doesn't change the mean of the box (or changes it the right amount)
  • ensures that the profile produced by a single cell matches what we would expect from a filtered delta function, within some tolerance

Here are the test plots produced for each filter with R=10:
tests.test_filtering.py--test_filters[2-10].pdf
tests.test_filtering.py--test_filters[1-10].pdf
tests.test_filtering.py--test_filters[0-10].pdf
tests.test_filtering.py--test_filters[4-10].pdf
tests.test_filtering.py--test_filters[3-10].pdf

Still TODO:

  • fix the first test for the exponential filter
  • set a reasonable passing criteria for the second test

@daviesje daviesje marked this pull request as ready for review October 7, 2024 08:33
Copy link
Member

@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 @daviesje -- I have a couple of suggestions that might help, but let's see

src/py21cmfast/src/filtering.c Show resolved Hide resolved
src/py21cmfast/src/filtering.c Outdated Show resolved Hide resolved
Comment on lines +110 to +120
lib.test_filter(
up(),
cp(),
ap(),
fo(),
ffi.cast("float *", input_box_centre.ctypes.data),
R,
R_param,
filter_flag,
ffi.cast("double *", output_box_centre.ctypes.data),
)
Copy link
Member

Choose a reason for hiding this comment

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

can we write a low-level wrapper function for this in the main code?

Copy link
Member

Choose a reason for hiding this comment

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

In fact, if instead we write the filter_box function as a low-level wrapper, we could perhaps write the test_filter function directly in python?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would the second option not require us to expose a bunch of fftw functions to the python wrapper?

Copy link
Member

Choose a reason for hiding this comment

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

Not necessarily -- we could just use np.fft or even pyfftw to do the FFT stuff in the wrapper function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't we be testing different funcitons at that point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you're okay with it, I would prefer to write wrappers for all the testing functions together in a separate PR

Copy link
Member

Choose a reason for hiding this comment

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

That's fine with me

tests/test_filtering.py Outdated Show resolved Hide resolved
tests/test_filtering.py Outdated Show resolved Hide resolved
tests/test_filtering.py Outdated Show resolved Hide resolved
Copy link
Member

@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 @daviesje this all looks good. Quite wide tolerances, but I think in conjunction with the plots, this is good.

@daviesje daviesje merged commit 30e5772 into v4-prep Oct 9, 2024
3 of 12 checks passed
@daviesje daviesje deleted the filter_func_tests branch October 9, 2024 09:47
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.

2 participants