# HG changeset patch # User Arun Giridhar # Date 1714059798 14400 # Node ID d9edf5bc95c716669ac79cc3dc0b6cb7bffd18f2 # Parent f3376b53696953a2bbc760d92847925ba17052cb# Parent 4401310ad7377a8b178e79dc2fba462a315240de maint: Merge default to bytecode-interpreter diff -r f3376b536969 -r d9edf5bc95c7 scripts/general/rat.m --- a/scripts/general/rat.m Thu Apr 25 10:33:46 2024 -0400 +++ b/scripts/general/rat.m Thu Apr 25 11:43:18 2024 -0400 @@ -98,11 +98,9 @@ if (nargin == 1) ## default norm tol = 1e-6 * norm (y, 1); - ## FIXME: tol becomes 0 if all inputs have Inf in them, - ## which breaks rat (complex (0, inf)); see bug #55198. else - if (! (isscalar (tol) && isnumeric (tol) && tol > 0)) - error ("rat: TOL must be a numeric scalar > 0"); + if (! (isscalar (tol) && isnumeric (tol) && tol >= 0)) + error ("rat: TOL must be a numeric scalar >= 0"); endif endif @@ -115,8 +113,8 @@ elseif (nargout <= 1) # string output realstr = rat (real (x), tol); imagstr = rat (imag (x), tol); - n = [repmat("(", rows(realstr), 1), realstr, repmat(") + (", rows(realstr), 1), imagstr, repmat(") * i", rows(imagstr), 1)]; - end + n = [repmat("(", rows (realstr), 1), realstr, repmat(") + (", rows (realstr), 1), imagstr, repmat(") * i", rows (imagstr), 1)]; + endif return endif @@ -268,10 +266,15 @@ %! assert (str(4, :), "(0 + 1/(3 + 1/(4 + 1/(4 + 1/(4 + 1/4))))) + (-1 + 1/(20 + 1/(2 + 1/(3 + 1/6))) ) * i"); ## Test complex exceptional inputs -%!test <55198> +%!test <*55198> %! assert (rat (complex (inf, 0)), "(Inf) + (0) * i"); %! assert (rat (complex (0, inf)), "(0) + (Inf) * i"); +## Test eval with complex inputs +%!test <*55198> +%! x = complex (0.5, pi); +%! assert (eval (rat (x)), x, 1e-6 * norm (x, 1)) + %!assert <*43374> (eval (rat (0.75)), [0.75]) ## Test input validation @@ -279,4 +282,4 @@ %!error rat (int8 (3)) %!error rat (1, "a") %!error rat (1, [1 2]) -%!error rat (1, -1) +%!error rat (1, -1) diff -r f3376b536969 -r d9edf5bc95c7 scripts/plot/appearance/view.m --- a/scripts/plot/appearance/view.m Thu Apr 25 10:33:46 2024 -0400 +++ b/scripts/plot/appearance/view.m Thu Apr 25 11:43:18 2024 -0400 @@ -74,11 +74,13 @@ az = x(1); el = x(2); elseif (numel (x) == 3) - [az, el] = cart2sph (x(1), x(2), x(3)); + if (x(2) == 0) + ## special case for negative 0 + [az, el] = cart2sph (x(2), x(1), x(3)); + else + [az, el] = cart2sph (-x(2), x(1), x(3)); + endif az *= 180/pi; - if (az != 0) - az += 90; # Special fix for bug #57800 - endif el *= 180/pi; elseif (x == 2) az = 0; @@ -141,7 +143,6 @@ %! hf = figure ("visible", "off"); %! unwind_protect %! plot3 ([0,1], [0,1], [0,1]); -%! view (3); %! view ([0, 0, 1]); %! [az, el] = view (); %! assert ([az, el], [0, 90], eps); @@ -149,22 +150,31 @@ %! close (hf); %! end_unwind_protect -%!test <65641> +%!test <*65641> %! hf = figure ("visible", "off"); %! unwind_protect %! plot3 ([0,1], [0,1], [0,1]); -%! view (3); +%! view ([1, 0, 0]); +%! [az, el] = view (); +%! assert ([az, el], [90, 0], eps); +%! view ([-1, 0, 0]); +%! [az, el] = view (); +%! assert ([az, el], [-90, 0], eps); +%! view ([0, 1, 0]); +%! [az, el] = view (); +%! assert ([az, el], [180, 0], eps); %! view ([0, -1, 0]); %! [az, el] = view (); %! assert ([az, el], [0, 0], eps); -%! view (3); -%! view ([1, 0, 0]); +%! view ([0, 0, 1]); %! [az, el] = view (); -%! assert ([az, el], [90, 0], eps); -%! view (3); +%! assert ([az, el], [0, 90], eps); +%! view ([0, 0, -1]); +%! [az, el] = view (); +%! assert ([az, el], [0, -90], eps); %! view ([1, 0.001, 0]); %! [az, el] = view (); -%! assert ([az, el], [0, 90 + 0.001*180/pi], eps); +%! assert ([az, el], [90 + 0.001*180/pi, 0], eps ("single")); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect