Repository navigation
fix: clear errors instead of crashes in analyses, stats and utils - #315
Merged
Merged
Conversation
…rors compute_sync reports only an unknown metric as unsupported and lets any other ValueError through. pair_connectivity and compute_nmPLV no longer squeeze the multitaper signal, which broke a single epoch, channel or frequency. statscluster raises a ValueError for an unknown test, runs the two t-tests with tail=-1 and refuses tail=-1 for F tests, as does statscondCluster. metaconn_matrix gains a plot argument that defaults to True. Outputs for inputs that worked before are bit-identical to master. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
normalizing raises a ValueError for an unknown type, generate_virtual_epoch for an odd channel count, and epochs_from_tasks for an onset event absent from the recording. create_epochs warns when the two participants give different numbers of epochs and still returns both lists. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
compute_nmPLV goes back to what master does: its values are the subject of #310, so making it run on a single epoch or channel would only produce new wrong numbers. The lower tail of the cluster tests is left for the work on cluster statistics: the call already succeeded for alpha >= 0.5, and the paired test permutes without keeping the pairs. statscluster keeps only the clear error for an unknown test. create_epochs also warns when the two lists of recordings differ in length, and no longer recommends equalising the counts, which does not make epochs correspond in time. The singleton-dimension test of pair_connectivity compares against a PLV written from its definition, and the normalizing test checks the Zscore and Logratio values. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
What this does
Eight small defects found by the October audit, all of the same kind: a call that crashed obscurely or reported the wrong cause now says what is wrong. No call that worked before returns a different value.
hypyp/analyses.pycompute_syncrewrote everyValueErrorasMetric type "..." not supported, sooptimization='bogus'was reported as "plv not supported". Only an unknown metric name gets that message now; any other error keeps its own (pair_connectivity cannot forward optimization/priority, and compute_sync masks all compute errors as "metric not supported" #306).pair_connectivitycalledsqueeze()on the multitaper signal. With a frequency list and a single epoch, a single channel per participant, or a single frequency such as[10, 11], a dimension disappeared and the next line raisedIndexError. Thesqueeze()is removed; it did nothing when no dimension had length one.hypyp/utils.pynormalizingraisedUnboundLocalErrorfor atypeother than'Zscore'or'Logratio'; it raises aValueErrornaming the two valid types.generate_virtual_epochfailed inside the solver for an odd number of channels; it raises aValueError, and its docstring example, which used three oscillators, uses four.epochs_from_tasksfailed withmin() iterable argument is emptywhen the onset event of a task was absent from the recording; theValueErrornames the task and the event.create_epochswarns when the two participants give different numbers of epochs, or different numbers of recordings. It returns what it returned before.hypyp/stats.pystatsclusterraisedUnboundLocalErrorfor an unknowntest; it raises aValueErrorlisting the valid names.metaconn_matrixgainsplot=True. The default draws as before;plot=Falseonly computes.Measured
pair_connectivityon a dimension of length one compares the result with a PLV written from its definition.pair_connectivitywith a list and a dictionary of frequencies,compute_nmPLV,normalizing, the cluster wrappers withtail0 and 1,metaconn_matrix,create_epochs,epochs_from_tasks,generate_virtual_epochwith a fixed seed) are bit-identical betweenmasterand this branch, shapes and dtypes included.Withdrawn after review
Two repairs were in the first version and were taken out, because each made a failing call return numbers that are not established as correct.
compute_nmPLVhas the samesqueeze()and the same crash, but the values it returns are the subject of compute_nmPLV applies the n:m exponent to the time axis instead of the channel axis, averages the wrong axis, and calls a deprecated helper #310. It is left as onmaster.statscluster(tail=-1)fails for the usualalpha, because the threshold is positive. Making it run is not a plain repair: the call already succeeds foralpha >= 0.5, the paired test permutes without keeping the pairs, andStat_obs_plotdrops negative values and keeps only the first of several clusters that share a p-value. All of this is left for the work on cluster statistics.statscluster(test='f multipleway')raises aTypeErroronmasterand still does.🤖 Generated with Claude Code