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


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

Submitted by:  Julien Bect <jbect>
Submitted on:  Sun 03 Mar 2013 06:37:22 PM UTC  
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: ConfirmedAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: GNU/Linux

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)

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>
Project 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

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>
Project 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:

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>
Project 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'.

(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.

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 File(s):

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
  • -unavailable- added by hardy (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by jordigh (Posted a comment)
  • -unavailable- added by jbect (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 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 07 Mar 2013 06:22:40 PM UTCjordighStatusNone=>Confirmed
    Sun 03 Mar 2013 07:02:45 PM UTCjbectAttached File-=>Added jbFixBugUnique.patch, #27561

    Back to the top

    Powered by Savane 3.1-cleanup1