Skip to content

Fix int-truncation bug in Waveform array sampling - #440

Merged
sgrava merged 1 commit into
mainfrom
sg/439-waveform-array-call-int-truncation
Aug 11, 2026
Merged

sgrava merged 1 commit into
mainfrom
sg/439-waveform-array-call-int-truncation

Conversation

@sgrava

@sgrava sgrava commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes Waveform.__call__ silently truncates float samples to int for np.ndarray input #439: np.vectorize in Waveform.__call__ inferred its output dtype from the first sample, silently truncating later float samples to int when that first value happened to be an int.
  • Pins the vectorized output dtype to float and casts values to float at the points where they could leak as int (_single_call, duration, and the constructors of ConstantWaveform, RampWaveform, BlackmanWaveform).

Test plan

  • Added regression tests in test_base_waveforms.py and test_derived_waveforms.py covering the int-leak and the array/list sampling mismatch from the issue repro.
  • Full test suite passes.

@sgrava
sgrava requested a review from v-vitale August 11, 2026 14:24
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-11 14:57 UTC

@v-vitale v-vitale left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for fixing this!

@sgrava
sgrava merged commit dd8151b into main Aug 11, 2026
29 checks passed
@sgrava
sgrava deleted the sg/439-waveform-array-call-int-truncation branch August 11, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Waveform.__call__ silently truncates float samples to int for np.ndarray input

2 participants