[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #36221] using ~ as optional output for unique
From: |
Ben Abbott |
Subject: |
[Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember |
Date: |
Wed, 18 Apr 2012 16:23:57 +0000 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19 |
Update of bug #36221 (project octave):
Status: Confirmed => In Progress
Assigned to: None => bpabbott
Operating System: Microsoft Windows => Any
_______________________________________________________
Follow-up Comment #3:
I wrote a simple function that isolates the problem.
function varargout = newdeal (varargin)
for n = 1:nargin
if (isargout (n))
varargout(n) = varargin(n);
endif
endfor
printf ("nargin = %d, nargout = %d, isargout(%d) = %d\n",
nargin (), nargout (), nargout (), isargout (nargout ()))
endfunction
%!shared a1, a2, a3, b1, b2, b3, c1, c3
%! [a1, b1, c1] = newdeal (1, 2, 3);
%! [a2, b2, ~] = newdeal (1, 2, 3);
%! [a3, b3, c3] = newdeal (1, 2, 3);
%!assert (a1, a2)
%!assert (a1, a3)
%!assert (b1, b2)
%!assert (b1, b3)
%!assert (c1, c3)
Running "test newdeal" ends with
test newdeal
nargin = 3, nargout = 3, isargout(3) = 1
nargin = 3, nargout = 3, isargout(3) = 0
***** shared a1, a2, a3, b1, b2, b3, c1, c3
[a1, b1, c1] = newdeal (1, 2, 3);
[a2, b2, ~] = newdeal (1, 2, 3);
[a3, b3, c3] = newdeal (1, 2, 3);
!!!!! test failed
element number 3 undefined in return list
shared variables
scalar structure containing the fields:
a1 = [](0x0)
a2 = [](0x0)
a3 = [](0x0)
b1 = [](0x0)
b2 = [](0x0)
b3 = [](0x0)
c1 = [](0x0)
c3 = [](0x0)
The parser expects the third argument to be set when the "~" is present. I
think this is intended. Thus, unique.m should be rewritten to use "(nargout ()
<= n)" in place of "isargout (n)". For example, modifying the simple example,
the version below passes all tests.
function varargout = newdeal (varargin)
nout = nargout ();
isargout = @(n) nout >= n;
for n = 1:nargin
if (isargout (n))
varargout(n) = varargin(n);
endif
endfor
printf ("nargin = %d, nargout = %d, isargout(%d) = %d\n",
nargin (), nargout (), nargout (), isargout (nargout ()))
endfunction
%!shared a1, a2, a3, b1, b2, b3, c1, c3
%! [a1, b1, c1] = newdeal (1, 2, 3);
%! [a2, b2, ~] = newdeal (1, 2, 3);
%! [a3, b3, c3] = newdeal (1, 2, 3);
%!assert (a1, a2)
%!assert (a1, a3)
%!assert (b1, b2)
%!assert (b1, b3)
%!assert (c1, c3)
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?36221>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember, anonymous, 2012/04/17
- Message not available
- [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember, John Hunt, 2012/04/18
- [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember,
Ben Abbott <=
- [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember, John W. Eaton, 2012/04/18
- [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember, John W. Eaton, 2012/04/18
- [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember, Ben Abbott, 2012/04/18
- [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember, John W. Eaton, 2012/04/18
- [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember, John W. Eaton, 2012/04/18
- Message not available
- Message not available
- [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember, John W. Eaton, 2012/04/18
- Message not available
- [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember, John W. Eaton, 2012/04/19
- [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember, John W. Eaton, 2012/04/19