Mercurial > octave
changeset 20907:40e1134ec984
maint: Periodic merge of stable to default
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Tue, 15 Dec 2015 19:25:43 -0500 |
parents | c640ea6a1612 (current diff) 9fe6db1dcc46 (diff) |
children | 0fb9de5b7903 |
files | scripts/general/private/__isequal__.m scripts/plot/util/__gnuplot_drawnow__.m |
diffstat | 6 files changed, 66 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/private/__isequal__.m Tue Dec 15 13:35:31 2015 -0800 +++ b/scripts/general/private/__isequal__.m Tue Dec 15 19:25:43 2015 -0500 @@ -64,7 +64,7 @@ if (t) ## Test that everything has the same number of dimensions. - t = all (ndims (x) == cellfun ("ndims", varargin)); + t = all (builtin ("ndims", x) == cellfun ("ndims", varargin)); endif if (t) @@ -72,7 +72,7 @@ nd = ndims (x); k = 1; do - t = all (size (x,k) == cellfun ("size", varargin, k)); + t = all (builtin ("size", x, k) == cellfun ("size", varargin, k)); until (!t || k++ == nd); endif
--- a/scripts/plot/util/__gnuplot_drawnow__.m Tue Dec 15 13:35:31 2015 -0800 +++ b/scripts/plot/util/__gnuplot_drawnow__.m Tue Dec 15 19:25:43 2015 -0500 @@ -185,8 +185,8 @@ || any (strcmp (term, {"canvas", "emf", "gif", "jpeg", ... "pbm", "png", "pngcairo", "svg"})))) ## Convert to inches - gnuplot_pos = gnuplot_pos / get (0, "screenpixelsperinch"); - gnuplot_size = gnuplot_size / get (0, "screenpixelsperinch"); + gnuplot_pos = gnuplot_pos / 72; + gnuplot_size = gnuplot_size / 72; endif if (all (gnuplot_size > 0)) terminals_with_size = {"canvas", "emf", "epslatex", "fig", ...
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@SizeTester/SizeTester.m Tue Dec 15 19:25:43 2015 -0500 @@ -0,0 +1,6 @@ +function x = SizeTester (desired_size) + + x = struct ("desired_size", desired_size); + x = class (x, "SizeTester"); + +endfunction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@SizeTester/numel.m Tue Dec 15 19:25:43 2015 -0500 @@ -0,0 +1,5 @@ +function n = numel (this) + + n = prod (this.desired_size); + +endfunction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@SizeTester/size.m Tue Dec 15 19:25:43 2015 -0500 @@ -0,0 +1,5 @@ +function s = size (this) + + s = this.desired_size; + +endfunction
--- a/test/classes/classes.tst Tue Dec 15 13:35:31 2015 -0800 +++ b/test/classes/classes.tst Tue Dec 15 19:25:43 2015 -0500 @@ -361,3 +361,49 @@ %% Trying to change to CPrecendenceTester3 > Snork %!error D = CPrecedenceTester3 (1); +############################################## +## Testing overridden size+numel method ## +## (builtin size method and similar methods ## +## use the size of the struct container) ## +############################################## + +%!shared st +%!test st = SizeTester ([1 1]); +%! assert (isequal (size (st), [1 1])) +%! assert (isequal (numel (st), 1)) +%!assert (isequal (ndims (st), 2)) +%!assert (isequal (rows (st), 1)) +%!assert (isequal (columns (st), 1)) +%!assert (isequal (st, st)) +%!assert (isscalar (st)) +%!assert (isvector (st)) + +%!test st = SizeTester ([1 2]); +%! assert (isequal (size (st), [1 2])) +%! assert (isequal (numel (st), 2)) +%!assert (isequal (ndims (st), 2)) +%!assert (isequal (rows (st), 1)) +%!xtest assert (isequal (columns (st), 2)) +%!assert (isequal (st, st)) # bug #44334 +%!xtest assert (not (isscalar (st))) # bug #44498 +%!assert (isvector (st)) + +%!test st = SizeTester ([2 3]); +%! assert (isequal (size (st), [2 3])) +%! assert (isequal (numel (st), 6)) +%!assert (isequal (ndims (st), 2)) +%!xtest assert (isequal (rows (st), 2)) +%!xtest assert (isequal (columns (st), 3)) +%!assert (isequal (st, st)) # bug #44334 +%!xtest assert (not (isscalar (st))) # bug #44498 +%!xtest assert (not (isvector (st))) # bug #44498 + +%!test st = SizeTester ([2 3 4]); +%! assert (isequal (size (st), [2 3 4])) +%! assert (isequal (numel (st), 24)) +%!xtest assert (isequal (ndims (st), 3)) +%!xtest assert (isequal (rows (st), 2)) +%!xtest assert (isequal (columns (st), 3)) +%!assert (isequal (st, st)) # bug #44334 +%!xtest assert (not (isscalar (st))) # bug #44498 +%!xtest assert (not (isvector (st))) # bug #44498