Skip to content

Commit 5f7da95

Browse files
fix test
1 parent 0d6d63a commit 5f7da95

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/unit_tests/utils/test_convolution.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,11 @@ def test_components_delta_gauss(
304304
"Test with different offset types and methods."
305305
# WHEN
306306
if sample_is_gauss:
307+
sample = gaussian_component
308+
resolution = DeltaFunction(name="Delta", center=0.1, area=2)
309+
else:
307310
sample = DeltaFunction(name="Delta", center=0.1, area=2)
308311
resolution = gaussian_component
309-
else:
310-
resolution = DeltaFunction(name="Delta", center=0.1, area=2)
311-
sample = gaussian_component
312312

313313
# THEN
314314
calculated_convolution = convolution(
@@ -322,10 +322,11 @@ def test_components_delta_gauss(
322322
# EXPECT
323323
expected_center = sample.center.value + resolution.center.value + expected_shift
324324
expected_area = sample.area.value * resolution.area.value
325+
width = sample.width.value if sample_is_gauss else resolution.width.value
325326
expected_result = (
326327
expected_area
327-
* np.exp(-0.5 * ((x - expected_center) / resolution.width.value) ** 2)
328-
/ (np.sqrt(2 * np.pi) * resolution.width.value)
328+
* np.exp(-0.5 * ((x - expected_center) / width) ** 2)
329+
/ (np.sqrt(2 * np.pi) * width)
329330
)
330331

331332
np.testing.assert_allclose(calculated_convolution, expected_result, atol=1e-10)

0 commit comments

Comments
 (0)