Open the context
Choose the project folder and name the files or behavior involved.
Compute a full discrete convolution of two finite numeric sequences. Check empty inputs, a single value and an asymmetric kernel, keeping output length equal to the sum of nonempty input lengths minus one.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
import math
def convolve(values, kernel):
if not all(map(math.isfinite, [*values, *kernel])):
raise ValueError("finite inputs required")
if not values or not kernel: return []
result = [0] * (len(values) + len(kernel) - 1)
for i, value in enumerate(values):
for j, weight in enumerate(kernel):
result[i + j] += value * weight
if not all(map(math.isfinite, result)):
raise ValueError("non-finite result")
return resultThe example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.