Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pylops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

"""

import logging

from .config import *
from .linearoperator import *
from .torchoperator import *
Expand All @@ -69,6 +71,9 @@
from .utils.utils import *
from .utils.wavelets import *

# Prevent no handler message if an application using PyLops does not configure logging
logging.getLogger(__name__).addHandler(logging.NullHandler())

try:
from .version import version as __version__
except ImportError:
Expand Down
6 changes: 3 additions & 3 deletions pylops/_torchoperator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import logging
import warnings

from pylops.utils import deps

Expand All @@ -22,8 +22,8 @@ def forward(ctx, x, forw, adj, device, devicetorch):

# check if data is moved to cpu and warn user
if ctx.device == "cpu" and ctx.devicetorch != "cpu":
logging.warning(
"pylops operator will be applied on the cpu "
warnings.warn(
"PyLops operator will be applied on the cpu "
"whilst the input torch vector is on "
"%s, this may lead to poor performance" % ctx.devicetorch
)
Expand Down
4 changes: 0 additions & 4 deletions pylops/avo/avo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"AVOLinearModelling",
]

import logging
from typing import List, Optional, Tuple, Union

import numpy as np
Expand All @@ -22,8 +21,6 @@
from pylops.utils.decorators import reshaped
from pylops.utils.typing import DTypeLike, NDArray

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)


def zoeppritz_scattering(
vp1: float,
Expand Down Expand Up @@ -659,7 +656,6 @@ def __init__(
elif linearization == "ps":
Gs = ps(theta, vsvp, n=self.nt0)
else:
logging.error("%s not an available " "linearization...", linearization)
raise NotImplementedError(
"%s not an available linearization..." % linearization
)
Expand Down
3 changes: 0 additions & 3 deletions pylops/avo/poststack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"PoststackInversion",
]

import logging
from typing import Optional, Tuple, Union

import numpy as np
Expand Down Expand Up @@ -32,8 +31,6 @@
from pylops.utils.signalprocessing import convmtx, nonstationary_convmtx
from pylops.utils.typing import NDArray, ShapeLike

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)


def _PoststackLinearModelling(
wav,
Expand Down
5 changes: 0 additions & 5 deletions pylops/avo/prestack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"PrestackInversion",
]

import logging
from typing import Optional, Tuple, Union

import numpy as np
Expand Down Expand Up @@ -36,8 +35,6 @@
from pylops.utils.signalprocessing import convmtx
from pylops.utils.typing import NDArray, ShapeLike

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)

_linearizations = {"akirich": 3, "fatti": 3, "ps": 3}


Expand Down Expand Up @@ -167,7 +164,6 @@ def PrestackLinearModelling(
elif callable(linearization):
G = linearization(theta, vsvp, n=nt0)
else:
logging.error("%s not an available linearization...", linearization)
raise NotImplementedError(
"%s not an available linearization..." % linearization
)
Expand Down Expand Up @@ -326,7 +322,6 @@ def PrestackWaveletModelling(
elif callable(linearization):
G = linearization(theta, vsvp, n=nt0)
else:
logging.error("%s not an available linearization...", linearization)
raise NotImplementedError(
"%s not an available linearization..." % linearization
)
Expand Down
8 changes: 3 additions & 5 deletions pylops/basicoperators/linearregression.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
__all__ = ["LinearRegression"]

import logging

import numpy.typing as npt

from pylops.basicoperators import Regression
from pylops.utils.typing import DTypeLike

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)


class LinearRegression(Regression):
r"""Linear regression.
Expand Down Expand Up @@ -76,5 +72,7 @@ class LinearRegression(Regression):
``order=1``.
"""

def __init__(self, taxis: npt.ArrayLike, dtype: DTypeLike = "float64", name: str = 'L'):
def __init__(
self, taxis: npt.ArrayLike, dtype: DTypeLike = "float64", name: str = "L"
):
super().__init__(taxis=taxis, order=1, dtype=dtype, name=name)
9 changes: 5 additions & 4 deletions pylops/basicoperators/matrixmult.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__all__ = ["MatrixMult"]

import logging
import warnings
from typing import Optional, Union

import numpy as np
Expand All @@ -12,7 +13,7 @@
from pylops.utils.backend import get_array_module
from pylops.utils.typing import DTypeLike, InputDimsLike, NDArray

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)
logger = logging.getLogger(__name__)


class MatrixMult(LinearOperator):
Expand Down Expand Up @@ -92,8 +93,8 @@ def __init__(

# Check if forceflat is needed and set it back to None otherwise
if otherdims is not None and forceflat is not None:
logging.warning(
"setting forceflat=None since otherdims!=None. "
logger.warning(
"Setting forceflat=None since otherdims!=None. "
"PyLops will automatically detect whether to return "
"a 1d or nd array based on the shape of the input "
"array."
Expand All @@ -102,7 +103,7 @@ def __init__(
# Check dtype for correctness (upcast to complex when A is complex)
if np.iscomplexobj(A) and not np.iscomplexobj(np.ones(1, dtype=dtype)):
dtype = A.dtype
logging.warning("Matrix A is a complex object, dtype cast to %s" % dtype)
warnings.warn("Matrix A is a complex object, dtype cast to %s" % dtype)
super().__init__(
dtype=np.dtype(dtype),
dims=dims,
Expand Down
5 changes: 0 additions & 5 deletions pylops/basicoperators/regression.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
__all__ = ["Regression"]

import logging

import numpy as np
import numpy.typing as npt

from pylops import LinearOperator
from pylops.utils.backend import get_array_module
from pylops.utils.typing import DTypeLike, NDArray

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)


class Regression(LinearOperator):
r"""Polynomial regression.
Expand Down Expand Up @@ -92,7 +88,6 @@ def __init__(
) -> None:
ncp = get_array_module(taxis)
if not isinstance(taxis, ncp.ndarray):
logging.error("t must be ndarray...")
raise TypeError("t must be ndarray...")
else:
self.taxis = taxis
Expand Down
6 changes: 3 additions & 3 deletions pylops/basicoperators/restriction.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)
from pylops.utils.typing import DTypeLike, InputDimsLike, IntNDArray, NDArray

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)
logger = logging.getLogger(__name__)


def _compute_iavamask(dims, axis, iava, ncp):
Expand Down Expand Up @@ -123,8 +123,8 @@ def __init__(
# check if forceflat is needed and set it back to None otherwise
if len(dims) > 2:
if forceflat is not None:
logging.warning(
f"setting forceflat=None since len(dims)={len(dims)}>2. "
logger.warning(
f"Setting forceflat=None since len(dims)={len(dims)}>2. "
f"PyLops will automatically detect whether to return "
f"a 1d or nd array based on the shape of the input"
f"array."
Expand Down
6 changes: 3 additions & 3 deletions pylops/basicoperators/spread.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
_rmatvec_numba_table,
)

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)
logger = logging.getLogger(__name__)


class Spread(LinearOperator):
Expand Down Expand Up @@ -184,7 +184,7 @@ def __init__(
self.engine = "numba"
else:
if engine == "numba" and jit is not None:
logging.warning(jit_message)
logger.warning(jit_message)
self.engine = "numpy"

# axes
Expand Down Expand Up @@ -222,7 +222,7 @@ def __init__(
if len(fh(0, 0)) == 2:
self.interp = True
if interp is not None and self.interp != interp:
logging.warning("interp has been overridden to %r.", self.interp)
logger.warning("interp has been overridden to %r.", self.interp)

def _matvec_numpy(self, x: NDArray) -> NDArray:
y = np.zeros(self.dimsd, dtype=self.dtype)
Expand Down
6 changes: 3 additions & 3 deletions pylops/basicoperators/sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pylops.utils.decorators import reshaped
from pylops.utils.typing import DTypeLike, InputDimsLike, NDArray

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)
logger = logging.getLogger(__name__)


class Sum(LinearOperator):
Expand Down Expand Up @@ -84,8 +84,8 @@ def __init__(
dimsd.pop(self.axis)
# check if forceflat is needed and set it back to None otherwise
if len(dims) > 2 and forceflat is not None:
logging.warning(
f"setting forceflat=None since len(dims)={len(dims)}>2. "
logger.warning(
f"Setting forceflat=None since len(dims)={len(dims)}>2. "
f"PyLops will automatically detect whether to return "
f"a 1d or nd array based on the shape of the input"
f"array."
Expand Down
3 changes: 0 additions & 3 deletions pylops/linearoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"aslinearoperator",
]

import logging
from abc import ABC, abstractmethod

import numpy as np
Expand Down Expand Up @@ -37,8 +36,6 @@
from pylops.utils.estimators import trace_hutchinson, trace_hutchpp, trace_nahutchpp
from pylops.utils.typing import DTypeLike, InputDimsLike, NDArray, ShapeLike

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)


class _LinearOperator(ABC):
"""Meta-class for Linear operator"""
Expand Down
4 changes: 2 additions & 2 deletions pylops/optimization/basesolver.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
__all__ = ["Solver"]

import functools
import logging
import time
import warnings
from abc import ABCMeta, abstractmethod
from typing import TYPE_CHECKING, Any

Expand Down Expand Up @@ -133,7 +133,7 @@ def _setpreallocate(self, preallocate: bool) -> None:
self.preallocate = preallocate if not self.isjax else False

if preallocate and self.isjax:
logging.warning(
warnings.warn(
"Preallocation is not supported for JAX arrays. "
"Setting preallocate to False."
)
Expand Down
4 changes: 0 additions & 4 deletions pylops/optimization/cls_leastsquares.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"PreconditionedInversion",
]

import logging
from typing import TYPE_CHECKING, Optional, Sequence, Tuple

import numpy as np
Expand All @@ -22,9 +21,6 @@
from pylops.linearoperator import LinearOperator


logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)


def _check_regularization_dims(
Regs: Sequence["LinearOperator"],
dataregs: Optional[Sequence[NDArray]] = None,
Expand Down
10 changes: 4 additions & 6 deletions pylops/optimization/cls_sparsity.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
if spgl1_message is None:
from spgl1 import spgl1 as ext_spgl1

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)
logger = logging.getLogger(__name__)


def _hardthreshold(x: NDArray, thresh: float) -> NDArray:
Expand Down Expand Up @@ -1825,9 +1825,7 @@ def run(
x, xupdate = self.step(x, showstep)
self.callback(x)
if xupdate <= self.tol:
logging.warning(
"update smaller that tolerance for " "iteration %d", self.iiter
)
logger.info("Update smaller that tolerance for iteration %d", self.iiter)
return x

def finalize(self, show: bool = False) -> None:
Expand Down Expand Up @@ -2208,8 +2206,8 @@ def run(
x, z, xupdate = self.step(x, z, showstep)
self.callback(x)
if xupdate <= self.tol:
logging.warning(
"update smaller that tolerance for " "iteration %d", self.iiter
logger.warning(
"Update smaller that tolerance for " "iteration %d", self.iiter
)
return x

Expand Down
3 changes: 0 additions & 3 deletions pylops/signalprocessing/_baseffts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging
import warnings
from enum import Enum, auto
from typing import Optional, Sequence, Union
Expand All @@ -18,8 +17,6 @@
)
from pylops.utils.typing import DTypeLike, InputDimsLike, NDArray

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)


class _FFTNorms(Enum):
ORTHO = auto()
Expand Down
6 changes: 3 additions & 3 deletions pylops/signalprocessing/bilinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pylops.utils.decorators import reshaped
from pylops.utils.typing import DTypeLike, InputDimsLike, IntNDArray, NDArray

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)
logger = logging.getLogger(__name__)


def _checkunique(iava: npt.ArrayLike) -> None:
Expand Down Expand Up @@ -106,8 +106,8 @@ def __init__(
# check if forceflat is needed and set it back to None otherwise
if ndims > 2:
if forceflat is not None:
logging.warning(
f"setting forceflat=None since len(dims)={len(dims)}>2. "
logger.warning(
f"Setting forceflat=None since len(dims)={len(dims)}>2. "
f"PyLops will automatically detect whether to return "
f"a 1d or nd array based on the shape of the input"
f"array."
Expand Down
4 changes: 0 additions & 4 deletions pylops/signalprocessing/chirpradon2d.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
__all__ = ["ChirpRadon2D"]

import logging

import numpy as np

from pylops import LinearOperator
Expand All @@ -10,8 +8,6 @@

from ._chirpradon2d import _chirp_radon_2d

logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)


class ChirpRadon2D(LinearOperator):
r"""2D Chirp Radon transform
Expand Down
Loading