Skip to content

convert crop_slices to tuple #26

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions fft_conv_pytorch/fft_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ def fft_conv(
output = irfftn(output_fr, dim=tuple(range(2, signal.ndim)))

# Remove extra padded values
crop_slices = [slice(None), slice(None)] + [
slice(0, (signal_size[i] - kernel.size(i) + 1), stride_[i - 2])
for i in range(2, signal.ndim)
]
crop_slices = tuple(
[slice(None), slice(None)] + [
slice(0, (signal_size[i] - kernel.size(i) + 1), stride_[i - 2])
for i in range(2, signal.ndim)
]
)
Comment on lines +135 to +140

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Converting crop_slices to a tuple resolves the deprecation warning. For improved efficiency and conciseness, consider constructing the tuple directly using tuple concatenation with a generator expression. This avoids creating intermediate lists.

crop_slices = (slice(None), slice(None)) + tuple(
    slice(0, (signal_size[i] - kernel.size(i) + 1), stride_[i - 2])
    for i in range(2, signal.ndim)
)

output = output[crop_slices].contiguous()

# Optionally, add a bias term before returning.
Expand Down