Skip to content

Fix grp2idx empty output shape - #501

Open
sahilphad07-sudo wants to merge 2 commits into
gnu-octave:mainfrom
sahilphad07-sudo:fix-grp2idx-empty-output
Open

sahilphad07-sudo wants to merge 2 commits into
gnu-octave:mainfrom
sahilphad07-sudo:fix-grp2idx-empty-output

Conversation

@sahilphad07-sudo

Copy link
Copy Markdown
Contributor

grp2idx returned an incorrectly shaped output for empty numeric vectors. MATLAB returns an empty column vector with size 0x1, while Octave returned an empty 0x0 matrix. This happened because unique (s(:)) returns g with size 0x0 when the input is empty. Fixed by ensuring an empty g has size 0x1.

BEFORE:

octave:> [g, gn, gl] = grp2idx(zeros(0, 1));
octave:> size(g)
ans =

   0   0

AFTER:

octave:> [g, gn, gl] = grp2idx(zeros(0, 1));
octave:> size(g)
ans =

   0   1

MATLAB:
>> [g, gn, gl] = grp2idx(zeros(0, 1));
>> size(g)

ans =

     0     1

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