# HG changeset patch # User Colin Macdonald # Date 1469988372 25200 # Node ID 116edbde73295d0aab1c13bca9a7c724819e5134 # Parent c7e1cb5183721ba9aaaa07594181e0e75207e3b0 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. diff -r c7e1cb518372 -r 116edbde7329 @pyobject/pyobject.m --- 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")