Skip to content

Commit 61d1cd9

Browse files
committed
Refactor array checks in unit tests to ensure consistent dtype handling
1 parent 9aafe94 commit 61d1cd9

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

cdl/tests/features/images/average_app_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def test_image_average():
3939
panel.objview.select_groups([0])
4040
panel.processor.compute_average()
4141
res_data = panel.objview.get_sel_objects(include_groups=True)[0].data
42-
check_array_result("Average", res_data, data)
42+
exp_data = np.array(data, dtype=float)
43+
check_array_result("Average", res_data, exp_data)
4344

4445

4546
if __name__ == "__main__":

cdl/tests/features/images/fft2d_unit_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def test_image_fft_interactive():
3434
data2 = alg.ifft2d(f)
3535
execenv.print("OK")
3636
execenv.print("Comparing original and FFT/iFFT images...", end=" ")
37-
check_array_result("Image FFT/iFFT", data2, data)
37+
check_array_result(
38+
"Image FFT/iFFT", np.array(data2.real, dtype=data.dtype), data, rtol=1e-3
39+
)
3840
execenv.print("OK")
3941

4042
images = [data, f.real, f.imag, np.abs(f), data2.real, data2.imag]

cdl/tests/features/images/processing_unit_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_image_calibration() -> None:
6868
# Test with a = 1 and b = 0: should do nothing
6969
p.a, p.b = 1.0, 0.0
7070
dst = cpi.compute_calibration(src, p)
71-
exp = src.data
71+
exp = np.array(src.data, dtype=float)
7272
check_array_result("Calibration[identity]", dst.data, exp)
7373

7474
# Testing with random values of a and b

cdl/tests/features/signals/fft1d_unit_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_signal_fft() -> None:
6666

6767
# Check that the inverse FFT reconstructs the original signal
6868
check_array_result("Cosine signal FFT/iFFT X reconstruction", s1.y, ifft.y.real)
69-
check_array_result("Cosine signal FFT/iFFT Y reconstruction", s1.x, ifft.x)
69+
check_array_result("Cosine signal FFT/iFFT Y reconstruction", s1.x, ifft.x.real)
7070

7171
# Check FFT properties
7272
mag = np.abs(fft.y)
@@ -112,7 +112,7 @@ def test_signal_magnitude_spectrum() -> None:
112112
check_scalar_result("Cosine negative frequency", fpk1, -freq, rtol=0.001)
113113

114114
# Check that the magnitude spectrum is correct
115-
check_array_result("Cosine signal magnitude spectrum X", mag.x, fft.x)
115+
check_array_result("Cosine signal magnitude spectrum X", mag.x, fft.x.real)
116116
check_array_result("Cosine signal magnitude spectrum Y", mag.y, np.abs(fft.y))
117117

118118

@@ -129,7 +129,7 @@ def test_signal_phase_spectrum() -> None:
129129
check_scalar_result("Cosine negative frequency", fpk1, -freq, rtol=0.001)
130130

131131
# Check that the phase spectrum is correct
132-
check_array_result("Cosine signal phase spectrum X", phase.x, fft.x)
132+
check_array_result("Cosine signal phase spectrum X", phase.x, fft.x.real)
133133
exp_phase = np.rad2deg(np.angle(fft.y))
134134
check_array_result("Cosine signal phase spectrum Y", phase.y, exp_phase)
135135

0 commit comments

Comments
 (0)