bugGNU Octave - Bugs: bug #56592, unique should have...

 
 

bug #56592: unique should have "legacy" option for Matlab compatibility

Submitted by:  Markus Ebner <seijikun>
Submitted on:  Mon 08 Jul 2019 05:38:49 PM UTC  
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

Wed 10 Jul 2019 08:50:12 PM UTC, comment #3: 

I implemented the "legacy" option for unique in this changeset (https://hg.savannah.gnu.org/hgweb/octave/rev/6eb32f0aea87).  This will be a part of the 6.1 release of Octave at the end of the year.  Since this is just an m-file, you can also download the file from the Mercurial repository if you need to see the change sooner.

Marking as fixed and closing report.

Rik <rik5>
Project Administrator
Wed 10 Jul 2019 12:29:49 AM UTC, comment #2: 

Matlab has gone back and forth on the "first"/"last" option.  It used to be that the Matlab default was "last", and it is still the default if you use the "legacy" option.  Likewise, if you use the "legacy" option then the second and third outputs of unique follow the shape of the input and will be row or column vectors depending on whether the input is a row or column vector.

Rik <rik5>
Project Administrator
Mon 08 Jul 2019 05:43:03 PM UTC, comment #1: 

Sorry:

original submission:

> The matlab documentation states that "last" is the default.
>
> Further: In Matlab, the second output is a column-vector, while the second output is a row-vector.


The Octave documentation states that "last" is the default.

Further: In Matlab, the second output is a column-vector, while the second output in Octave is a row-vector.

Markus Ebner <seijikun>
Mon 08 Jul 2019 05:38:49 PM UTC, original submission:  

The unique() function seems to have an incorrect default value.
The [matlab documentation states https://uk.mathworks.com/help/matlab/ref/unique.html?searchHighlight=unique&s_tid=doc_srchtitle]:

C = unique(A,occurrence) specifies which indices to return in case of repeated values. occurrence can be 'first' (default) or 'last'.

The matlab documentation states that "last" is the default.

Further: In Matlab, the second output is a column-vector, while the second output is a row-vector.

Matlab R2019a:

[a,b] = unique([1,2,3,1])

a =
     1     2     3

b =
     1
     2
     3

Octave 5.1.0:

[a,b] = unique([1,2,3,1])

a =
   1   2   3

b =
   4   2   3

Markus Ebner <seijikun>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by seijikun (Submitted the item)
  •  

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

    Only project members can vote.

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-07-10 rik5 StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2019-07-10 rik5 Release5.1.0 => dev
        Summaryunique() output-dimensions and (first/last)-option default incompatible => unique should have "legacy" option for Matlab compatibility
    2019-07-09 mtmiller StatusNone => Confirmed

    Back to the top


    Powered by Savane 3.5