bugGNU Octave - Bugs: bug #38460, Option 'stable' missing from...


bug #38460: Option 'stable' missing from unique()

Submitter:  Julien Bect <jbect>
Submitted:  Sun 03 Mar 2013 06:37:22 PM UTC
Category:  Interpreter Severity:  1 - Wish
Priority:  3 - Low Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Jump to the original submission

Tue 06 Aug 2019 05:01:11 AM UTC, comment #7: 

I implemented the "stable" option in this cset 27291:c4f9a0f097a3.  This will be a part of the 6.1 release.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Sun 20 Nov 2016 09:39:11 PM UTC, comment #6: 

This issue (missing option "stable" in unique.m) is still present in Octave 4.2.0.

Hartmut <hardy>
Thu 07 Mar 2013 08:56:08 PM UTC, comment #5: 

I just checked in a different way of verifying the arguments (http://hg.savannah.gnu.org/hgweb/octave/rev/51b13fe45a94).

I hadn't really looked at this code until the check-in brought it to my attention, but the original code before Julien wasn't very well written.  unique() was calling unique() recursively on it's own input arguments which is slow.  Also, ismember () is a relatively slow m-file compared to built-in functions like strcmp() and any().  I re-coded and benchmarked and there was a 9.5% savings with my changes so I checked them in.

Rik <rik5>
Group administrator
Thu 07 Mar 2013 06:22:40 PM UTC, comment #4: 

Okay, I rebased your patch and edited the commit message a little:


You may wish to remove your original local copy of this patch with

hg strip -r e014f0449eda8

I'm leaving this bug report open, since the issue of "stable" being unimplemented is still open.

By the way, TMW has changed how unique.m presents its output, and has added the quite horrible "legacy" and "2012a" options to switch between these two. I'm not sure what Octave should do about this.

Jordi Gutiérrez Hermoso <jordigh>
Group administrator
Mon 04 Mar 2013 07:41:24 AM UTC, comment #3: 

I don't have time to implement 'stable' right now, perhaps later (I have other bugfixes in my todo list before that one). I will psot a note here if I start doing it, but if someone else whants to do it first... ;-)

Anyway, I think that my patch is a correct bugfix: not for the fact that 'stable' is missing, but for the fact that unique was intended to err out but didn't, see lines 60--62:

      elseif (optfirst + optlast + optrows != nargin-1)
        error ("unique: invalid option");

Julien Bect <jbect>
Sun 03 Mar 2013 10:12:00 PM UTC, comment #2: 

I don't think this is really a fix. Can you implement stable? Implementing a stable sort isn't really difficult.

Note that a lot of Octave commands don't error out when you give them the wrong options. For example, null(1,"lol") and rank(1,"lol") don't error out either. If you really want to fix this, there are many other places where you can do this. Note that sometimes we shouldn't error out if Matlab doesn't do it either, but if Matlab does error out, we might not necessarily out ourselves.

Jordi Gutiérrez Hermoso <jordigh>
Group administrator
Sun 03 Mar 2013 07:02:45 PM UTC, comment #1: 

The attached patch fixes part of the problem: now an error is triggered by the unknown option 'stable'.

octave:1> unique({'a', 'c', 'b'}, 'stable')
error: unique: invalid option
error: called from:
error:   /media/data/sources/octave2/scripts/set/unique.m at line 61, column 9

(file #27561)

Julien Bect <jbect>
Sun 03 Mar 2013 06:37:22 PM UTC, original submission:  

The unique() function in Matlab has a 'stable' option that is currently missing in Octave.

octave:1> unique({'a', 'c', 'b'}, 'stable')
ans =
  [1,1] = a
  [1,2] = b
  [1,3] = c

The result should be {'a', 'c', 'b'} with the 'stable' option.

Note that, since Octave currently does not support 'stable' according to the help text, the above command should trigger an error.

Julien Bect <jbect>


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

Attach Files:

Attached Files
file #27561:  jbFixBugUnique.patch added by jbect (1KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by jbect (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.


    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-08-06 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2019-01-12 jwe Severity3 - Normal 1 - Wish
        Priority5 - Normal 3 - Low
        Item GroupMatlab Compatibility Feature Request
    2013-03-07 jordigh StatusNone Confirmed
    2013-03-03 jbect Attached File- Added jbFixBugUnique.patch, #27561

    Back to the top

    Powered by Savane 3.12