Skip to content

Fix anova2 empty input handling - #499

Closed
sahilphad07-sudo wants to merge 2 commits into
gnu-octave:mainfrom
sahilphad07-sudo:fix-anova2-empty-input
Closed

sahilphad07-sudo wants to merge 2 commits into
gnu-octave:mainfrom
sahilphad07-sudo:fix-anova2-empty-input

Conversation

@sahilphad07-sudo

@sahilphad07-sudo sahilphad07-sudo commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

anova2 failed with an undefined RIdx error when the input x was empty.

This change adds handling for the empty-input case and returns [NaN, NaN], matching MATLAB behavior.

Before

octave:> anova2([], 1, "off")
error: 'RIdx' undefined

After

octave:> anova2([], 1, "off")
ans =

   NaN   NaN

MATLAB Behavior

>> anova2([], 1, "off")
ans =

   NaN   NaN

Regression Test Added

  • Empty input case

Test Results

All existing and new anova2 BISTs pass:

@pr0m1th3as

Copy link
Copy Markdown
Member

Thank you for looking into this, but I am closing this without merging.

Returning [NaN, NaN] covers only one of the cases MATLAB handles: it gives three p-values when reps > 1, keeps the class of a single input, and returns atab and stats, so [p, t, s] = anova2 ([], 1, 'off') still crashed here. Since an empty design has nothing to analyse, anova2 now refuses it with a clear error, which closes #497.

A kind request for future contributions: please test the whole surface a change touches before opening a PR, every output and the neighbouring cases, not only the one reported. A partial fix costs more review time than it saves, and we would much rather receive fewer PRs that are complete.

@pr0m1th3as pr0m1th3as closed this Sep 24, 2026
@sahilphad07-sudo

sahilphad07-sudo commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Thank you for the detailed feedback, @pr0m1th3as From next time, I’ll make sure to test the full behavior surface, including neighboring and edge cases, before opening future PRs. I appreciate the guidance.

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.

2 participants