Skip to content

Commit

Permalink
add unit test slope vs. dips
Browse files Browse the repository at this point in the history
Signed-off-by: beramos <[email protected]>
  • Loading branch information
Beramos committed Mar 4, 2024
1 parent b9b47ce commit 3bd3386
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pytests/test_signalutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
from numpy.testing import assert_array_almost_equal

from pylops.utils.signalprocessing import convmtx, nonstationary_convmtx
from pylops.utils.signalprocessing import convmtx, nonstationary_convmtx, slope_estimate

par1 = {"nt": 51, "nh": 7, "imag": 0, "dtype": "float32"} # odd sign, odd filt, real
par1j = {
Expand Down Expand Up @@ -90,3 +90,18 @@ def test_nonstationary_convmtx(par):
y = np.dot(H[: par["nt"]], x)
y1 = np.dot(H1, x)
assert_array_almost_equal(y, y1, decimal=4)


def test_slope_estimation_dips():
"""Slope estimation using the Structure tensor algorithm should
apply regularisation (some slopes are set to zero)
while dips should not use regularisation."""

img_test = np.identity(20) # generate test with -45° angle
eps = 0.09 # set a regularisation parameter that will be exceeded

slopes, _ = slope_estimate(img_test, dips=False, eps=eps)
slopes_dips, _ = slope_estimate(img_test, dips=True, eps=eps)

assert np.any(np.isclose(slopes, 0.0))
assert not np.any(np.isclose(slopes_dips, 0.0))

0 comments on commit 3bd3386

Please sign in to comment.