bugGNU Octave - Bugs: bug #36221, using ~ as optional output for...

 
 

bug #36221: using ~ as optional output for unique causes error in ismember

Submitted by:  None
Submitted on:  Tue 17 Apr 2012 07:52:37 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedAssigned to: John W. Eaton <jwe>
Originator Name: Yoerik de VoogdOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.6.1
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Thu 19 Apr 2012 08:25:36 PM UTC, comment #13:

I checked in the following change to fix this problem:

http://hg.savannah.gnu.org/hgweb/octave/rev/000cd393f3c1

This fix will appear in the upcoming 3.6.2 release.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Thu 19 Apr 2012 01:27:00 PM UTC, comment #12:

Ben, I see the problem now. It must be related to varargout processing because I don't see it if I use a function like

Sorry about the confusion.

I'll check it out.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Thu 19 Apr 2012 11:21:59 AM UTC, comment #11:

I'm seeing the error below

When "~" is used for the last output and it has not been set.

For example, using the newdeal.m function below

The "~" works as expected, except for the last output.

Ben Abbott <bpabbott>
Project Member
Thu 19 Apr 2012 01:04:42 AM UTC, comment #10:

If the output is not used, I see no reason to require it to be set.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Thu 19 Apr 2012 12:11:25 AM UTC, comment #9:

Did you intend for the changeset to require the nth output be set? As below, for example?

Ben Abbott <bpabbott>
Project Member
Wed 18 Apr 2012 07:15:37 PM UTC, comment #8:

Oh, wait. Now I remember, Matlab has the special "~" that allows outputs to be ignored, but it doesn't seem to provide a way for a function to check to see whether the outputs are ignored. At least it doesn't seem to have an isargout function.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Wed 18 Apr 2012 07:07:48 PM UTC, comment #7:

The originally reported problem is fixed by the changeset I committed, so I don't think there is anything in unique.m that needs to be changed.

I also don't think that we should require that unused outputs must be set to something. Does matlab really require that? So you have to write things like

Anyway, what is left to fix?

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Wed 18 Apr 2012 06:54:10 PM UTC, comment #6:

John,

I think you are correct that "~" is sticky, and should be fixed.

Regarding omitting setting the value for output's corresponding to "~", I also agree that would be useful. Reading the help string, my impression was that the function still needed to set the value, but that the result would be ignored when returned.

I don't think we need to copy the behavior of Matlab in this instance, but Matlab does throw an error if the output corresponding to "~" is not set.

How would you like to proceed? Should the parser be fixed, or shall unique.m be modified to use nargout instead ?

Ben Abbott <bpabbott>
Project Member
Wed 18 Apr 2012 06:48:23 PM UTC, comment #5:

This bug is fixed with the changeset:

http://hg.savannah.gnu.org/hgweb/octave/rev/6131fead3135

See also bug #36260

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Wed 18 Apr 2012 05:21:52 PM UTC, comment #4:

With your function

I see the following:

I think that in the third call to newdeal, isargout(3) should be true and the call should succeed. It seems like isargout is somehow sticky and I don't think it should be. Or am I misunderstanding something here?

Also, if isargout(N) is true, I think we should be able to completely omit setting a value for that output. The point of isargout is to be able to avoid calculation, but I think it would annoying if we still had to set values (even if just []) for unused output values.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Wed 18 Apr 2012 04:23:57 PM UTC, comment #3:

I wrote a simple function that isolates the problem.

Running "test newdeal" ends with

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.

Ben Abbott <bpabbott>
Project Member
Wed 18 Apr 2012 02:59:28 PM UTC, comment #2:

this bug is not limited to unique, see #36240

meanwhile you can just avoid trailing ~
(beware that once unique has been called with a trailing ~,
clear unique is mandatory for it to work again)

output from 56 to 60 : same as yours
output from 61 to 64 : works

John Hunt <huntj>
Wed 18 Apr 2012 01:32:19 AM UTC, comment #1:

I tracked the problem a bit. The script below results in an empty "jj" when unique is called the last time.

Ben Abbott <bpabbott>
Project Member
Tue 17 Apr 2012 07:52:37 AM UTC, original submission:

When using ~ as the optional 3rd output argument in the unique function the ismember function using the optional 'rows' argument causes the error:

The error can be reproduced using the code

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by huntj (Posted a comment)
  • -unavailable- added by bpabbott (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 11 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 19 Apr 2012 08:25:36 PM UTCjweStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Thu 19 Apr 2012 12:11:36 AM UTCbpabbottAssigned tobpabbott=>jwe
    Wed 18 Apr 2012 06:54:10 PM UTCbpabbottStatusFixed=>In Progress
      Open/ClosedClosed=>Open
    Wed 18 Apr 2012 06:48:22 PM UTCjweStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Wed 18 Apr 2012 04:23:57 PM UTCbpabbottStatusConfirmed=>In Progress
      Assigned toNone=>bpabbott
      Operating SystemMicrosoft Windows=>Any
    Wed 18 Apr 2012 01:32:19 AM UTCbpabbottStatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1