diff --git a/pylops/signalprocessing/patch2d.py b/pylops/signalprocessing/patch2d.py index 3aa157a5..11b93fca 100644 --- a/pylops/signalprocessing/patch2d.py +++ b/pylops/signalprocessing/patch2d.py @@ -28,6 +28,7 @@ def patch2d_design( nwin: Tuple[int, int], nover: Tuple[int, int], nop: Tuple[int, int], + verb: bool = True, ) -> Tuple[ Tuple[int, int], Tuple[int, int], @@ -51,6 +52,9 @@ def patch2d_design( Number of samples of overlapping part of window. nop : :obj:`tuple` Size of model in the transformed domain. + verb : :obj:`bool`, optional + Verbosity flag. If ``verb==True``, print the data + and model windows start-end indices Returns ------- @@ -79,21 +83,22 @@ def patch2d_design( mwins_inends = ((mwin0_ins, mwin0_ends), (mwin1_ins, mwin1_ends)) # print information about patching - logging.warning("%d-%d windows required...", nwins0, nwins1) - logging.warning( - "data wins - start:%s, end:%s / start:%s, end:%s", - dwin0_ins, - dwin0_ends, - dwin1_ins, - dwin1_ends, - ) - logging.warning( - "model wins - start:%s, end:%s / start:%s, end:%s", - mwin0_ins, - mwin0_ends, - mwin1_ins, - mwin1_ends, - ) + if verb: + logging.warning("%d-%d windows required...", nwins0, nwins1) + logging.warning( + "data wins - start:%s, end:%s / start:%s, end:%s", + dwin0_ins, + dwin0_ends, + dwin1_ins, + dwin1_ends, + ) + logging.warning( + "model wins - start:%s, end:%s / start:%s, end:%s", + mwin0_ins, + mwin0_ends, + mwin1_ins, + mwin1_ends, + ) return nwins, dims, mwins_inends, dwins_inends @@ -276,10 +281,7 @@ def __init__( self.taps = np.vstack(taps).reshape(3, 3, nwin[0], nwin[1]) # define scalings - if scalings is None: - self.scalings = [1.0] * nwins - else: - self.scalings = scalings + self.scalings = [1.0] * nwins if scalings is None else scalings # check if operator is applied to all windows simultaneously self.simOp = False @@ -318,7 +320,7 @@ def _apply_taper(self, ywins, iwin0, iwin1): ywins[iwin0, iwin1] = self.taps[1, 1] * ywins[iwin0, iwin1] return ywins - @reshaped() + @reshaped def _matvec_savetaper(self, x: NDArray) -> NDArray: ncp = get_array_module(x) if self.tapertype is not None: @@ -365,7 +367,7 @@ def _rmatvec_savetaper(self, x: NDArray) -> NDArray: ).reshape(self.dims[2], self.dims[3]) return y - @reshaped() + @reshaped def _matvec_nosavetaper(self, x: NDArray) -> NDArray: ncp = get_array_module(x) if self.tapertype is not None: diff --git a/pylops/signalprocessing/patch3d.py b/pylops/signalprocessing/patch3d.py index 71ffe341..26cd9086 100644 --- a/pylops/signalprocessing/patch3d.py +++ b/pylops/signalprocessing/patch3d.py @@ -28,6 +28,7 @@ def patch3d_design( nwin: Tuple[int, int, int], nover: Tuple[int, int, int], nop: Tuple[int, int, int], + verb: bool = True, ) -> Tuple[ Tuple[int, int, int], Tuple[int, int, int], @@ -51,6 +52,9 @@ def patch3d_design( Number of samples of overlapping part of window. nop : :obj:`tuple` Size of model in the transformed domain. + verb : :obj:`bool`, optional + Verbosity flag. If ``verb==True``, print the data + and model windows start-end indices Returns ------- @@ -90,25 +94,26 @@ def patch3d_design( ) # print information about patching - logging.warning("%d-%d-%d windows required...", nwins0, nwins1, nwins2) - logging.warning( - "data wins - start:%s, end:%s / start:%s, end:%s / start:%s, end:%s", - dwin0_ins, - dwin0_ends, - dwin1_ins, - dwin1_ends, - dwin2_ins, - dwin2_ends, - ) - logging.warning( - "model wins - start:%s, end:%s / start:%s, end:%s / start:%s, end:%s", - mwin0_ins, - mwin0_ends, - mwin1_ins, - mwin1_ends, - mwin2_ins, - mwin2_ends, - ) + if verb: + logging.warning("%d-%d-%d windows required...", nwins0, nwins1, nwins2) + logging.warning( + "data wins - start:%s, end:%s / start:%s, end:%s / start:%s, end:%s", + dwin0_ins, + dwin0_ends, + dwin1_ins, + dwin1_ends, + dwin2_ins, + dwin2_ends, + ) + logging.warning( + "model wins - start:%s, end:%s / start:%s, end:%s / start:%s, end:%s", + mwin0_ins, + mwin0_ends, + mwin1_ins, + mwin1_ends, + mwin2_ins, + mwin2_ends, + ) return nwins, dims, mwins_inends, dwins_inends @@ -485,10 +490,7 @@ def __init__( self.taps[-1, -1, -1] = taprightbottomback # define scalings - if scalings is None: - self.scalings = [1.0] * nwins - else: - self.scalings = scalings + self.scalings = [1.0] * nwins if scalings is None else scalings # check if operator is applied to all windows simultaneously self.simOp = False @@ -576,7 +578,7 @@ def _apply_taper(self, ywins, iwin0, iwin1, iwin2): ywins[iwin0, iwin1, iwin2] = self.taps[1, 1, 1] * ywins[iwin0, iwin1, iwin2] return ywins - @reshaped() + @reshaped def _matvec_savetaper(self, x: NDArray) -> NDArray: ncp = get_array_module(x) if self.tapertype is not None: @@ -630,7 +632,7 @@ def _rmatvec_savetaper(self, x: NDArray) -> NDArray: ).reshape(self.dims[3], self.dims[4], self.dims[5]) return y - @reshaped() + @reshaped def _matvec_nosavetaper(self, x: NDArray) -> NDArray: ncp = get_array_module(x) if self.tapertype is not None: @@ -727,7 +729,7 @@ def _matvec_nosavetaper(self, x: NDArray) -> NDArray: ] += xxwin return y - @reshaped() + @reshaped def _rmatvec_nosavetaper(self, x: NDArray) -> NDArray: ncp = get_array_module(x) ncp_sliding_window_view = get_sliding_window_view(x) diff --git a/pylops/signalprocessing/sliding1d.py b/pylops/signalprocessing/sliding1d.py index 9ddc4842..b203c1a1 100644 --- a/pylops/signalprocessing/sliding1d.py +++ b/pylops/signalprocessing/sliding1d.py @@ -28,6 +28,7 @@ def sliding1d_design( nwin: int, nover: int, nop: int, + verb: bool = True, ) -> Tuple[int, int, Tuple[NDArray, NDArray], Tuple[NDArray, NDArray]]: """Design Sliding1D operator @@ -46,6 +47,9 @@ def sliding1d_design( Number of samples of overlapping part of window. nop : :obj:`tuple` Size of model in the transformed domain. + verb : :obj:`bool`, optional + Verbosity flag. If ``verb==True``, print the data + and model windows start-end indices Returns ------- @@ -70,17 +74,18 @@ def sliding1d_design( mwins_inends = (mwin_ins, mwin_ends) # print information about patching - logging.warning("%d windows required...", nwins) - logging.warning( - "data wins - start:%s, end:%s", - dwin_ins, - dwin_ends, - ) - logging.warning( - "model wins - start:%s, end:%s", - mwin_ins, - mwin_ends, - ) + if verb: + logging.warning("%d windows required...", nwins) + logging.warning( + "data wins - start:%s, end:%s", + dwin_ins, + dwin_ends, + ) + logging.warning( + "model wins - start:%s, end:%s", + mwin_ins, + mwin_ends, + ) return nwins, dim, mwins_inends, dwins_inends diff --git a/pylops/signalprocessing/sliding2d.py b/pylops/signalprocessing/sliding2d.py index ad0be2f5..27c40089 100644 --- a/pylops/signalprocessing/sliding2d.py +++ b/pylops/signalprocessing/sliding2d.py @@ -60,6 +60,7 @@ def sliding2d_design( nwin: int, nover: int, nop: Tuple[int, int], + verb: bool = True, ) -> Tuple[int, Tuple[int, int], Tuple[NDArray, NDArray], Tuple[NDArray, NDArray]]: """Design Sliding2D operator @@ -78,6 +79,9 @@ def sliding2d_design( Number of samples of overlapping part of window. nop : :obj:`tuple` Size of model in the transformed domain. + verb : :obj:`bool`, optional + Verbosity flag. If ``verb==True``, print the data + and model windows start-end indices Returns ------- @@ -102,17 +106,18 @@ def sliding2d_design( mwins_inends = (mwin_ins, mwin_ends) # print information about patching - logging.warning("%d windows required...", nwins) - logging.warning( - "data wins - start:%s, end:%s", - dwin_ins, - dwin_ends, - ) - logging.warning( - "model wins - start:%s, end:%s", - mwin_ins, - mwin_ends, - ) + if verb: + logging.warning("%d windows required...", nwins) + logging.warning( + "data wins - start:%s, end:%s", + dwin_ins, + dwin_ends, + ) + logging.warning( + "model wins - start:%s, end:%s", + mwin_ins, + mwin_ends, + ) return nwins, dims, mwins_inends, dwins_inends diff --git a/pylops/signalprocessing/sliding3d.py b/pylops/signalprocessing/sliding3d.py index 49324230..db052180 100644 --- a/pylops/signalprocessing/sliding3d.py +++ b/pylops/signalprocessing/sliding3d.py @@ -28,6 +28,7 @@ def sliding3d_design( nwin: Tuple[int, int], nover: Tuple[int, int], nop: Tuple[int, int, int], + verb: bool = True, ) -> Tuple[ Tuple[int, int], Tuple[int, int, int], @@ -51,6 +52,9 @@ def sliding3d_design( Number of samples of overlapping part of window. nop : :obj:`tuple` Size of model in the transformed domain. + verb : :obj:`bool`, optional + Verbosity flag. If ``verb==True``, print the data + and model windows start-end indices Returns ------- @@ -79,21 +83,22 @@ def sliding3d_design( mwins_inends = ((mwin0_ins, mwin0_ends), (mwin1_ins, mwin1_ends)) # print information about patching - logging.warning("%d-%d windows required...", nwins0, nwins1) - logging.warning( - "data wins - start:%s, end:%s / start:%s, end:%s", - dwin0_ins, - dwin0_ends, - dwin1_ins, - dwin1_ends, - ) - logging.warning( - "model wins - start:%s, end:%s / start:%s, end:%s", - mwin0_ins, - mwin0_ends, - mwin1_ins, - mwin1_ends, - ) + if verb: + logging.warning("%d-%d windows required...", nwins0, nwins1) + logging.warning( + "data wins - start:%s, end:%s / start:%s, end:%s", + dwin0_ins, + dwin0_ends, + dwin1_ins, + dwin1_ends, + ) + logging.warning( + "model wins - start:%s, end:%s / start:%s, end:%s", + mwin0_ins, + mwin0_ends, + mwin1_ins, + mwin1_ends, + ) return nwins, dims, mwins_inends, dwins_inends