Skip to content

Fix nanmedian validation - #519

Open
sahilphad07-sudo wants to merge 2 commits into
gnu-octave:mainfrom
sahilphad07-sudo:fix-nanmedian-validation
Open

sahilphad07-sudo wants to merge 2 commits into
gnu-octave:mainfrom
sahilphad07-sudo:fix-nanmedian-validation

Conversation

@sahilphad07-sudo

Copy link
Copy Markdown
Contributor

nanmedian did not correctly validate non-finite scalar and vector dimension arguments. This change adds validation for non-finite dimensions and regression tests for both cases.

Before

octave:1> nanmedian (ones (3), Inf)
ans =

   1   1   1
   1   1   1
   1   1   1

octave:2> nanmedian (ones (3), [1 Inf])
ans =

   1   1   1

Both calls returned results instead of raising dimension-validation errors.

After

octave:1> nanmedian (ones (3), Inf)
error: nanmedian: DIM must be a positive integer.

octave:2> nanmedian (ones (3), [1 Inf])
error: nanmedian: VECDIM must be a vector of positive integers.

MATLAB Behavior

>> nanmedian (ones (3), Inf)
Error using prctile
Dimension argument must be a positive integer scalar, a vector of unique positive integers, or 'all'.

>> nanmedian (ones (3), [1 Inf])
Error using prctile
Dimension argument must be a positive integer scalar, a vector of unique positive integers, or 'all'.

MATLAB rejects both invalid dimension arguments, consistent with the validation added in this change.

Regression Tests Added

  • Non-finite scalar dimension (Inf).
  • Non-finite dimension within a vector ([1 Inf]).

Test Results

  • 24 out of 24 nanmedian BISTs pass.

This branch has not been deployed

No deployments
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.

1 participant