fix: raise ValueError for non-1D data array in Channel.__init__#288
Merged
Conversation
Before this fix, passing a 2D array as data (e.g. shape (n, n)) would silently pass the len() length check when the first dimension matched len(time_index). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…#287 Extends the ndim guard to TimeSeriesBase.__init__ (time_index) and Label.__init__ (data, text_data), so that any 2D+ array raises a clear ValueError instead of silently corrupting the stored index or data. IntervalLabel is unaffected — it reshapes (m, 2) time_index to 1D before reaching the parent __init__. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
83e36b0 to
cd5ef5e
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.
Closes #287.
Adds
ndim != 1guards to prevent 2D+ arrays from silently passinglen()-based length checks:Channel.__init__—data(extended with test for 2Dtime_index)TimeSeriesBase.__init__—time_index(new)Label.__init__—dataandtext_data(new)IntervalLabelis unaffected: it reshapes an(m, 2)time_indexto 1D before the parent__init__is called, so the new guard never trips for valid interval input.Test plan
test_channel_creation_2d_data_raises— 2Ddataand 2Dtime_indexonChannelraiseValueErrortest_label_creation_2d_raises— 2Ddata,text_data, andtime_indexonLabelraiseValueError