Skip to content

Commit

Permalink
Merge branch 'master' into reduce-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
cako committed Dec 29, 2021
2 parents a8b947c + 566456d commit 8bdd3bb
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 41 deletions.
13 changes: 13 additions & 0 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ To ensure that everything has been setup correctly, run tests:
Make sure no tests fail, this guarantees that the installation has been successfull.

Finally, to ensure consistency in the coding style of our developers we rely on
`pre-commit <https://pre-commit.com>`_ to perform a series of checks when you are
ready to commit and push some changes. This is accomplished by means of git hooks
that have been configured in the ``.pre-commit-config.yaml`` file.

In order to setup such hooks in your local repository, run:

.. code-block:: bash
>> pre-commit install
Later on, ``pre-commit`` will automatically run for you and propose additional stylistic changes to your commits.

If using Conda environment, always remember to activate the conda environment every time you open
a new *bash* shell by typing:

Expand Down
24 changes: 12 additions & 12 deletions examples/plot_causalintegration.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@

# Visualize data and inversion
fig, axs = plt.subplots(1, 2, figsize=(18, 5))
axs[0].plot(t, y, "k", LineWidth=3, label="data")
axs[0].plot(t, yn, "--g", LineWidth=3, label="noisy data")
axs[0].plot(t, y, "k", lw=3, label="data")
axs[0].plot(t, yn, "--g", lw=3, label="noisy data")
axs[0].legend()
axs[0].set_title("Causal integration")
axs[1].plot(t, x, "k", LineWidth=8, label="original")
axs[1].plot(t[1:-1], xder[1:-1], "r", LineWidth=3, label="numerical derivative")
axs[1].plot(t, xreg, "g", LineWidth=3, label="regularized")
axs[1].plot(t, xp, "m", LineWidth=3, label="preconditioned")
axs[1].plot(t, x, "k", lw=8, label="original")
axs[1].plot(t[1:-1], xder[1:-1], "r", lw=3, label="numerical derivative")
axs[1].plot(t, xreg, "g", lw=3, label="regularized")
axs[1].plot(t, xp, "m", lw=3, label="preconditioned")
axs[1].legend()
axs[1].set_title("Inverse causal integration")

Expand Down Expand Up @@ -163,13 +163,13 @@

# Visualize data and inversion at a chosen xlocation
fig, axs = plt.subplots(1, 2, figsize=(18, 5))
axs[0].plot(t, y[:, nx // 2], "k", LineWidth=3, label="data")
axs[0].plot(t, yn[:, nx // 2], "--g", LineWidth=3, label="noisy data")
axs[0].plot(t, y[:, nx // 2], "k", lw=3, label="data")
axs[0].plot(t, yn[:, nx // 2], "--g", lw=3, label="noisy data")
axs[0].legend()
axs[0].set_title("Causal integration")
axs[1].plot(t, x[:, nx // 2], "k", LineWidth=8, label="original")
axs[1].plot(t, xder[:, nx // 2], "r", LineWidth=3, label="numerical derivative")
axs[1].plot(t, xreg[:, nx // 2], "g", LineWidth=3, label="regularized")
axs[1].plot(t, xp[:, nx // 2], "m", LineWidth=3, label="preconditioned")
axs[1].plot(t, x[:, nx // 2], "k", lw=8, label="original")
axs[1].plot(t, xder[:, nx // 2], "r", lw=3, label="numerical derivative")
axs[1].plot(t, xreg[:, nx // 2], "g", lw=3, label="regularized")
axs[1].plot(t, xp[:, nx // 2], "m", lw=3, label="preconditioned")
axs[1].legend()
axs[1].set_title("Inverse causal integration")
10 changes: 7 additions & 3 deletions pylops/signalprocessing/FFT.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def __init__(
if self.fftshift_after:
if self.real:
warnings.warn(
"Using fftshift_after with real=True. fftshift should only be applied after a complex FFT. This is rarely intended behavior but if it is, ignore this message."
"Using fftshift_after with real=True. fftshift should only be "
"applied after a complex FFT. This is rarely intended behavior "
"but if it is, ignore this message."
)
self.f = np.fft.fftshift(self.f)

Expand Down Expand Up @@ -236,8 +238,10 @@ def __init__(
fftshift_after,
dtype,
)
if len(dims) == 1:
self.dims = np.array((dims[0],))
if isinstance(dims, int) or len(dims) == 1:
self.dims = (
np.array((dims,)) if isinstance(dims, int) else np.array((dims[0],))
)
self.dims_t = self.dims.copy()
self.dims_t[self.dir] = self.nfft
self.dims_fft = self.dims.copy()
Expand Down
18 changes: 7 additions & 11 deletions pylops/signalprocessing/Radon2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@
try:
from numba import jit

from ._Radon2D_numba import (
_create_table_numba,
_hyperbolic_numba,
_indices_2d_numba,
_indices_2d_onthefly_numba,
_linear_numba,
_parabolic_numba,
)
from ._Radon2D_numba import (_create_table_numba, _hyperbolic_numba,
_indices_2d_numba, _indices_2d_onthefly_numba,
_linear_numba, _parabolic_numba)
except ModuleNotFoundError:
jit = None

Expand Down Expand Up @@ -225,9 +220,10 @@ def Radon2D(
dh, dt = np.abs(haxis[1] - haxis[0]), np.abs(taxis[1] - taxis[0])
dpx = dh / dt
pxaxis = pxaxis * dpx
haxisunitless = haxis // dh
if centeredh:
haxisunitless -= nh // 2
if not centeredh:
haxisunitless = haxis // dh
else:
haxisunitless = np.arange(nh) - nh // 2
dims = (npx, nt)
dimsd = (nh, nt)

Expand Down
22 changes: 9 additions & 13 deletions pylops/signalprocessing/Radon3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@
try:
from numba import jit

from ._Radon3D_numba import (
_create_table_numba,
_hyperbolic_numba,
_indices_3d_numba,
_indices_3d_onthefly_numba,
_linear_numba,
_parabolic_numba,
)
from ._Radon3D_numba import (_create_table_numba, _hyperbolic_numba,
_indices_3d_numba, _indices_3d_onthefly_numba,
_linear_numba, _parabolic_numba)
except ModuleNotFoundError:
jit = None

Expand Down Expand Up @@ -236,13 +231,14 @@ def Radon3D(
dt = np.abs(taxis[1] - taxis[0])
dpy = dhy / dt
pyaxis = pyaxis * dpy
hyaxisunitless = hyaxis // dhy
dpx = dhx / dt
pxaxis = pxaxis * dpx
hxaxisunitless = hxaxis // dhx
if centeredh:
hyaxisunitless -= nhy // 2
hxaxisunitless -= nhx // 2
if not centeredh:
hyaxisunitless = hyaxis // dhy
hxaxisunitless = hxaxis // dhx
else:
hyaxisunitless = np.arange(nhy) - nhy // 2
hxaxisunitless = np.arange(nhx) - nhx // 2

# create grid for py and px axis
hyaxisunitless, hxaxisunitless = np.meshgrid(
Expand Down
4 changes: 2 additions & 2 deletions tutorials/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@
x = FFTop.H * X

fig, axs = plt.subplots(2, 1, figsize=(12, 8))
axs[0].plot(f, np.abs(X), "k", LineWidth=2)
axs[0].plot(f, np.abs(X), "k", lw=2)
axs[0].set_xlim(0, 30)
axs[0].set_title("Data(frequency domain)")
axs[1].plot(t, x, "k", LineWidth=2)
axs[1].plot(t, x, "k", lw=2)
axs[1].set_title("Data(time domain)")
axs[1].axis("tight")

Expand Down

0 comments on commit 8bdd3bb

Please sign in to comment.