Mercurial > pytave
changeset 295:116edbde7329
pyobject: Add overloaded ndims
By default, ndims doesn't respect the output of size. IIRC, there
is a related upstream Octave bug about this, forget which one.
* @pyobject/pyobject.m (@pyobject/ndims): New method.
author | Colin Macdonald <cbm@m.fsf.org> |
---|---|
date | Sun, 31 Jul 2016 11:06:12 -0700 |
parents | c7e1cb518372 |
children | fadb4475e75d |
files | @pyobject/pyobject.m |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/@pyobject/pyobject.m Sat Jul 30 01:18:02 2016 -0700 +++ b/@pyobject/pyobject.m Sun Jul 31 11:06:12 2016 -0700 @@ -198,6 +198,11 @@ n = prod (sz); endfunction + function n = ndims (x) + assert (nargin == 1) + n = length (size (x)); + endfunction + function r = end (x, index_pos, num_indices) assert (nargin == 3) assert (isscalar (index_pos)) @@ -250,6 +255,7 @@ %!assert (size (a), [3 4 5]) %!assert (size (a, 3), 5) %!assert (numel (a), 60) +%!assert (ndims (a), 3) %!shared %!assert (char (pyeval ("None")), "None")