Skip to content

Commit df6b2a1

Browse files
author
Yuri R. Tonin
committed
Adjustments to base_tests and cuda_cupy_tests for also clipping phase
1 parent e839713 commit df6b2a1

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

test/accelerate_tests/base_tests/array_utils_test.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,17 @@ def test_interpolated_shift(self):
244244

245245
def test_clip_object_to_range(self):
246246
data = np.ones((5, 5), dtype=COMPLEX_TYPE)
247-
data[2, 4] = 20.0 * np.exp(1j * np.pi / 2)
247+
data[2, 4] = 20.0 * np.exp(1j * -np.pi / 2)
248248
data[3, 1] = 0.2 * np.exp(1j * np.pi / 3)
249249

250-
clip_min = 0.5
251-
clip_max = 2.0
250+
clip_min_mag = 0.5
251+
clip_max_mag = 2.0
252+
clip_min_phase = -np.pi / 4
253+
clip_max_phase = np.pi / 4
252254
expected_out = np.ones_like(data)
253-
expected_out[2, 4] = 2.0 * np.exp(1j * np.pi / 2)
255+
expected_out[2, 4] = 2.0 * np.exp(1j * -np.pi / 2)
254256
expected_out[3, 1] = 0.5 * np.exp(1j * np.pi / 3)
255-
au.clip_complex_magnitudes_to_range(data, clip_min, clip_max)
257+
au.clip_object_to_range(data, clip_min_mag, clip_max_mag, clip_min_phase, clip_max_phase)
256258
np.testing.assert_array_almost_equal(data, expected_out, decimal=7) # floating point precision I guess...
257259

258260
def test_crop_pad_1(self):

test/accelerate_tests/cuda_cupy_tests/array_utils_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,9 @@ def test_clip_object_to_range_UNITY(self):
410410
B = B.astype(np.complex64)
411411
B_gpu = cp.asarray(B)
412412

413-
au.clip_complex_magnitudes_to_range(B, 0.2,0.8)
413+
au.clip_object_to_range(B, 0.2,0.8, -np.pi/4, np.pi/4)
414414
CMK = gau.ClipObjectKernel()
415-
CMK.clip_object_to_range(B_gpu, 0.2, 0.8)
415+
CMK.clip_object_to_range(B_gpu, (0.2, 0.8, -np.pi/4, np.pi/4))
416416

417417
np.testing.assert_allclose(B_gpu.get(), B, rtol=1e-6, atol=1e-6,
418418
err_msg="The magnitudes of the array have not been clipped as expected")

0 commit comments

Comments
 (0)