|
20 | 20 | from pylops.signalprocessing import Convolve1D, Convolve2D, ConvolveND |
21 | 21 | from pylops.utils import dottest |
22 | 22 |
|
| 23 | +np.random.seed(10) |
| 24 | + |
23 | 25 | # filters |
24 | 26 | nfilt = (5, 6, 5) |
25 | 27 | h1 = triang(nfilt[0], sym=True) |
@@ -195,6 +197,43 @@ def test_Convolve1D_method_error(): |
195 | 197 | ) |
196 | 198 |
|
197 | 199 |
|
| 200 | +@pytest.mark.parametrize("par", [(par1_3d), (par2_3d)]) |
| 201 | +@pytest.mark.parametrize("axes", [(0, 1), (0, 1, 2, 0)]) |
| 202 | +def test_ConvolveND_axes_length_error(par, axes): |
| 203 | + """Error raised when axes do not match the filter dimensionality.""" |
| 204 | + with pytest.raises(ValueError, match="axes must contain one axis per dimension of h"): |
| 205 | + ConvolveND( |
| 206 | + dims=(par["nz"], par["ny"], par["nx"]), |
| 207 | + h=np.random.normal(size=nfilt), |
| 208 | + offset=par["offset"], |
| 209 | + axes=axes, |
| 210 | + ) |
| 211 | + |
| 212 | + |
| 213 | +@pytest.mark.parametrize("par", [(par1_3d), (par2_3d)]) |
| 214 | +@pytest.mark.parametrize("axes", [(0, 0, 2), (0, 1, -2)]) |
| 215 | +def test_ConvolveND_axes_unique_error(par, axes): |
| 216 | + """Error raised for repeated axes, including negative aliases.""" |
| 217 | + with pytest.raises(ValueError, match="axes must be unique"): |
| 218 | + ConvolveND( |
| 219 | + dims=(par["nz"], par["ny"], par["nx"]), |
| 220 | + h=np.random.normal(size=nfilt), |
| 221 | + offset=par["offset"], |
| 222 | + axes=axes, |
| 223 | + ) |
| 224 | + |
| 225 | + |
| 226 | +@pytest.mark.parametrize("par", [(par1_3d), (par2_3d)]) |
| 227 | +@pytest.mark.parametrize("hshape", [nfilt, (1, 1, 1)]) |
| 228 | +def test_ConvolveND_shape_error(par, hshape): |
| 229 | + """Error raised when the filter has more dimensions than the model.""" |
| 230 | + with pytest.raises(ValueError, match="h cannot have more dimensions than dims"): |
| 231 | + ConvolveND( |
| 232 | + dims=(par["ny"], par["nx"]), |
| 233 | + h=np.random.normal(size=hshape), |
| 234 | + ) |
| 235 | + |
| 236 | + |
198 | 237 | @pytest.mark.parametrize("dims", [nfilt[0] * 4, (3, nfilt[0] * 4)]) |
199 | 238 | @pytest.mark.parametrize("hlen", ["short", "long"]) |
200 | 239 | def test_Convolve1D_hstar_contiguous(dims, hlen): |
|
0 commit comments