Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug Fix for Issue #851: Simulator.simple_ir: width should always be > self.dt
Description of the Bug
The
simple_ir
function constructs an impulse response by appending a series of ones after a certain delay. However, when thewidth
parameter is smaller thanself.dt
, the calculation:results in an empty array (
h_ones = []
). This leads to an incorrect output where the expected impulse response does not contain the required1
value.Steps to Replicate the Bug
simple_ir
.width
smaller thanself.dt
, for example:Actual Output:
[0, 0, 0]
Expected Output:
[0, 0, 0, 1]
Proposed Fix
To ensure that at least one bin is always created, we modify the
h_ones
calculation to:How This Fix Works
width < self.dt
.h_ones
array, which was the root cause of the issue.dtype=int
) to match expected results[0, 0, 0, 1]
instead of[0. 0. 0. 1.]
.Testing the Fix
Run the following test case:
Before Fix:
[0, 0, 0]
(Buggy output)After Fix:
[0, 0, 0, 1]
(Correct output)Pull Request Guidelines Followed
Preview Output: