Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure sliding ops work with fp32 #549

Merged
merged 2 commits into from
Nov 22, 2023
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
6 changes: 4 additions & 2 deletions pylops/signalprocessing/sliding1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def Sliding1D(

# create tapers
if tapertype is not None:
tap = taper(nwin, nover, tapertype=tapertype)
tap = taper(nwin, nover, tapertype=tapertype).astype(Op.dtype)
tapin = tap.copy()
tapin[:nover] = 1
tapend = tap.copy()
Expand All @@ -172,7 +172,9 @@ def Sliding1D(
if tapertype is None:
OOp = BlockDiag([Op for _ in range(nwins)])
else:
OOp = BlockDiag([Diagonal(taps[itap].ravel()) * Op for itap in range(nwins)])
OOp = BlockDiag(
[Diagonal(taps[itap].ravel(), dtype=Op.dtype) * Op for itap in range(nwins)]
)

combining = HStack(
[
Expand Down
6 changes: 4 additions & 2 deletions pylops/signalprocessing/sliding2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def Sliding2D(

# create tapers
if tapertype is not None:
tap = taper2d(dimsd[1], nwin, nover, tapertype=tapertype)
tap = taper2d(dimsd[1], nwin, nover, tapertype=tapertype).astype(Op.dtype)
tapin = tap.copy()
tapin[:nover] = 1
tapend = tap.copy()
Expand All @@ -206,7 +206,9 @@ def Sliding2D(
if tapertype is None:
OOp = BlockDiag([Op for _ in range(nwins)])
else:
OOp = BlockDiag([Diagonal(taps[itap].ravel()) * Op for itap in range(nwins)])
OOp = BlockDiag(
[Diagonal(taps[itap].ravel(), dtype=Op.dtype) * Op for itap in range(nwins)]
)

combining = HStack(
[
Expand Down
7 changes: 5 additions & 2 deletions pylops/signalprocessing/sliding3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,16 @@ def Sliding3D(

# create tapers
if tapertype is not None:
tap = taper3d(dimsd[2], nwin, nover, tapertype=tapertype)
tap = taper3d(dimsd[2], nwin, nover, tapertype=tapertype).astype(Op.dtype)

# transform to apply
if tapertype is None:
OOp = BlockDiag([Op for _ in range(nwins)], nproc=nproc)
else:
OOp = BlockDiag([Diagonal(tap.ravel()) * Op for _ in range(nwins)], nproc=nproc)
OOp = BlockDiag(
[Diagonal(tap.ravel(), dtype=Op.dtype) * Op for _ in range(nwins)],
nproc=nproc,
)

hstack = HStack(
[
Expand Down