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

i.ifft: Add Test Suite #5264

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jayneel-shah18
Copy link
Contributor

This PR introduces a test suite for the i.ifft GRASS GIS module. The test suite is aimed at verifying the module’s core functionality, confirming statistical accuracy, and testing various edge cases to ensure stable and reliable performance.

Key Updates in this PR:

  • Validate IFFT output for linearity, scaling, coefficient symmetry, masking, and reconstruction.
  • Ensure correct handling of input rasters for real and imaginary components.
  • Test IFFT behavior under different masking and raster configurations.

Test Case Additions

  • Linearity Property: Test the linearity of the inverse fast Fourier transform (IFFT) by combining two rasters (test_linearity_property).
  • Scaling Property: Validate the scaling property of the IFFT to ensure ifft(2.5 * x) == 2.5 * ifft(x) (test_scaling_property).
  • Coefficient Symmetry: Test if the IFFT preserves symmetry in the real-valued output (test_coefficient_symmetry).
  • Mask Functionality: Ensure proper behavior when masking is applied (test_mask_functionality).
  • IFFT Reconstruction: Check if the IFFT can accurately reconstruct the original raster from the FFT (test_ifft_reconstruction).

Performance

The test suite execution times:

  • Windows: 3.137s
  • macOS: 2.027s
  • Ubuntu: 2.555s

This test suite enhances the reliability of the i.ifft module by covering a broad spectrum of cases. Looking forward to feedback and potential refinements!

@github-actions github-actions bot added Python Related code is in Python module imagery tests Related to Test Suite labels Mar 2, 2025
Comment on lines +52 to +67
self.assertModule(
"i.ifft",
real=self.real_input,
imaginary=self.imag_input,
output=self.output_raster,
overwrite=True,
)
self.assertRasterExists(self.output_raster)

self.assertModule(
"i.ifft",
real="real_input2",
imaginary="imag_input2",
output="output_raster2",
overwrite=True,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

What are these 2 i.ifft runs testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These two i.ifft runs generate two separate rasters by performing the inverse Fourier transform on different input sets. The outputs are then combined into a third raster (output_raster_sum) using the summed inputs (real_input_sum, imag_input_sum). Finally, the results of output_raster_sum are compared against reference statistics, which were derived using the same method. This test validates the linearity property of the inverse Fourier transform by ensuring that IFFT(A) + IFFT(B) = IFFT(A + B).

self.temp_rasters.append("output_sym")

self.runModule(
"r.mapcalc", expression="shifted = output_sym[5, 5]", overwrite=True
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain this test more?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test checks whether i.ifft preserves symmetry in the real-valued output. The input (real_sym) is designed to be symmetric around column 5, and imag_zero ensures there is no imaginary component. I wanted to compare the flipped raster with the raster generated by i.ifft and initially, I attempted to use r.flip to create the shifted raster, but it did not work as expected. So instead, I used shifted = output_sym[5, 5] to obtain a reference value and computed sym_diff = abs(output_sym - shifted) to find deviations from symmetry. Then this is compared against reference statistics which validates that the IFFT output maintains the expected symmetry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imagery module Python Related code is in Python tests Related to Test Suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants