Mercurial > octave
comparison libinterp/corefcn/data.cc @ 31278:076c8f94d7f4
Allow empty input for dimension vector (bug #63181).
* libinterp/corefcn/utils.cc (get_dimensions): Allow empty input (additionally
to row or column vector input). Change comment to describe actual behavior.
* libinterp/corefcn/data.cc: Adjust test code and description.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 09 Oct 2022 13:21:29 +0200 |
parents | 9e9f5f1e8ec2 |
children | c0f1a817c058 |
comparison
equal
deleted
inserted
replaced
31277:185799b2a566 | 31278:076c8f94d7f4 |
---|---|
4651 | 4651 |
4652 /* | 4652 /* |
4653 ## Tests for bug #47298 | 4653 ## Tests for bug #47298 |
4654 ## Matlab requires the size to be a row vector. In that logic, it supports | 4654 ## Matlab requires the size to be a row vector. In that logic, it supports |
4655 ## n to be a 1x0 vector (returns 0x0) but not a 0x1 vector. Octave supports | 4655 ## n to be a 1x0 vector (returns 0x0) but not a 0x1 vector. Octave supports |
4656 ## any vector and therefore must support 0x1, 1x0, and 0x0x1 (but not 0x1x1). | 4656 ## row and column vectors and therefore must support 0x1, 1x0, and 0x1x1. |
4657 ## Also any empty input results in a 0x0 output. | |
4657 %!test <*47298> | 4658 %!test <*47298> |
4658 %! fcns = {@zeros, @ones, @inf, @nan, @NA, @i, @pi, @e}; | 4659 %! fcns = {@zeros, @ones, @inf, @nan, @NA, @i, @pi, @e}; |
4659 %! for idx = 1:numel (fcns) | 4660 %! for idx = 1:numel (fcns) |
4660 %! fcn = fcns{idx}; | 4661 %! fcn = fcns{idx}; |
4661 %! assert (fcn (zeros (1, 0)), zeros (0, 0)); | 4662 %! assert (fcn (zeros (1, 0)), zeros (0, 0)); |
4662 %! assert (fcn (zeros (0, 1)), zeros (0, 0)); | 4663 %! assert (fcn (zeros (0, 1)), zeros (0, 0)); |
4663 %! assert (fcn (zeros (0, 1, 1)), zeros (0, 0)); | 4664 %! assert (fcn (zeros (0, 1, 1)), zeros (0, 0)); |
4664 %! fail ([func2str(fcn) " ([])"]); | 4665 %! assert (fcn (zeros ([])), zeros (0, 0)); |
4665 %! fail ([func2str(fcn) " (zeros (0, 0, 1))"]); | 4666 %! assert (fcn (zeros (0, 0, 1)), zeros (0, 0)); |
4666 %! endfor | 4667 %! endfor |
4667 */ | 4668 */ |
4668 | 4669 |
4669 DEFUN (zeros, args, , | 4670 DEFUN (zeros, args, , |
4670 doc: /* -*- texinfo -*- | 4671 doc: /* -*- texinfo -*- |