refactor: nspikeTrain constructor takes sampleRate instead of binwidth#72
Merged
iahncajigas merged 2 commits intomainfrom Mar 22, 2026
Merged
refactor: nspikeTrain constructor takes sampleRate instead of binwidth#72iahncajigas merged 2 commits intomainfrom
iahncajigas merged 2 commits intomainfrom
Conversation
Change the 3rd positional argument of nspikeTrain.__init__ from binwidth (seconds) to sampleRate (Hz), matching the user-facing mental model. The default changes from 0.001 to 1000.0 (same effective rate: 1/0.001 = 1000). This fixes several silent bugs where callers passed sampleRate-like values (10.0, 20.0) as the 3rd arg, which were misinterpreted as binwidth (giving sampleRate=0.1 or 0.05 Hz instead of intended 10 or 20 Hz). Changes: - nstat/core.py: Constructor signature, nstCopy, fromStructure - nstat/trial.py: nstColl collapsed train construction - 8 test files: Convert explicit binwidth values to sampleRate - 2 notebook builder tools: Convert delta to 1.0/delta Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The MATLAB gold fixtures were generated with binwidth as 3rd arg. Values 10.0 and 2.0 in nstcoll/history tests were MATLAB binwidths (not sampleRate), needing conversion: 10.0→0.1, 2.0→0.5. Also convert fixture-loaded binwidth via 1.0/binwidth. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bd2f676 to
16c6343
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
nspikeTrain.__init__3rd positional argument frombinwidth(seconds) tosampleRate(Hz)0.001→1000.0(same effective rate)Test plan
pytest tests/test_nspiketrain_fidelity.py tests/test_workflow_fidelity.py tests/test_trial_fidelity.pypass locally (29 passed)nspikeTrain([0.1, 0.3], 'n1', 1000.0, 0.0, 0.5).isSigRepBinary()returns True🤖 Generated with Claude Code