Skip to content

Commit 3bd3386

Browse files
committed
add unit test slope vs. dips
Signed-off-by: beramos <[email protected]>
1 parent b9b47ce commit 3bd3386

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pytests/test_signalutils.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
from numpy.testing import assert_array_almost_equal
44

5-
from pylops.utils.signalprocessing import convmtx, nonstationary_convmtx
5+
from pylops.utils.signalprocessing import convmtx, nonstationary_convmtx, slope_estimate
66

77
par1 = {"nt": 51, "nh": 7, "imag": 0, "dtype": "float32"} # odd sign, odd filt, real
88
par1j = {
@@ -90,3 +90,18 @@ def test_nonstationary_convmtx(par):
9090
y = np.dot(H[: par["nt"]], x)
9191
y1 = np.dot(H1, x)
9292
assert_array_almost_equal(y, y1, decimal=4)
93+
94+
95+
def test_slope_estimation_dips():
96+
"""Slope estimation using the Structure tensor algorithm should
97+
apply regularisation (some slopes are set to zero)
98+
while dips should not use regularisation."""
99+
100+
img_test = np.identity(20) # generate test with -45° angle
101+
eps = 0.09 # set a regularisation parameter that will be exceeded
102+
103+
slopes, _ = slope_estimate(img_test, dips=False, eps=eps)
104+
slopes_dips, _ = slope_estimate(img_test, dips=True, eps=eps)
105+
106+
assert np.any(np.isclose(slopes, 0.0))
107+
assert not np.any(np.isclose(slopes_dips, 0.0))

0 commit comments

Comments
 (0)