bugGNU Octave - Bugs: bug #61765, matlab compatibility - issorted...

 
 

bug #61765: matlab compatibility - issorted can't handle arrays

Submitter:  Nicholas Jankowski <nrjank>
Submitted:  Wed 05 Jan 2022 05:07:46 PM UTC
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  None Assigned to:  None
Originator Name:  Nicholas Jankowski Open/Closed:  * Open
Release:  * dev Operating System:  * Any
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Wed 05 Jan 2022 08:37:38 PM UTC, comment #5: 

thanks, will try to remember.  also realized a doc change like this prob. could have pushed to stable.

Nicholas Jankowski <nrjank>
Project Member
Wed 05 Jan 2022 06:50:52 PM UTC, comment #4: 
Markus Mützel <mmuetzel>
Project Member
Wed 05 Jan 2022 06:44:05 PM UTC, comment #3: 

Just a general note wrt to commit messages:
Please, use imperative tense instead of telegram style when possible.
Start sentences with a capital letter.

Markus Mützel <mmuetzel>
Project Member
Wed 05 Jan 2022 06:33:06 PM UTC, comment #2: 

pushed a doc change to http://hg.savannah.gnu.org/hgweb/octave/rev/0cb3f48da9da
that changes array to vector and matrix as appropriate in the docstring.

Nicholas Jankowski <nrjank>
Project Member
Wed 05 Jan 2022 06:17:35 PM UTC, comment #1: 

ok, apart from the cellstr issue, this appears to be a more general array handling issue: 

Matlab

issorted([1 2 3; 2 3 4])
ans =
  logical
   1

issorted([1 2 3; 2 3 2])
ans =
  logical
   0

Octave:

issorted([1 2 3; 2 3 4])
error: issorted: needs a vector

I see in the matlab 6.5 (R13, 2002) release notes when issorted was added, it states 'vectors' and only allows the option 'rows', and seems similar in function to Octave's current version.  I see in 2017 release notes that additional options were added. so somewhere in between it was expanded to matrices (working on columns) and nD arrays (working on 1st non-singleton dimension), added the DIM option, and sorting options, and later added a few Name/Value options.

note that the help for Octave uses the word 'arrays'.  Seems until any updates are made, we should at least fix the doc to be accurate.

Nicholas Jankowski <nrjank>
Project Member
Wed 05 Jan 2022 05:07:46 PM UTC, original submission:  

This appears to be a compatibility concern, not sure if this is from a change in matlab behavior:

Matlab 2021b:

abc = ['a1'; 'a2'; 'a3'];

issorted (abc)
ans =
  logical
   1

issorted({abc})
ans =
  logical
   1

abc = ['a1'; 'a3'; 'a2'];

issorted (abc)
ans =
  logical
   0

issorted({abc})
ans =
  logical
   1

abc = ['a1'; 'b2'; 'a3'];

issorted (abc)
ans =
  logical
   0

issorted({abc})
ans =
  logical
   1

I included cellstrings because it seemed to be the only way octave would try to process it:
Octave 7.0.1 (hg id: d00ae0ad8f89)

abc = ['a1'; 'a2'; 'a3'];

issorted(abc)
error: issorted: needs a vector

issorted({abc})
warning: multi-row character matrix converted to a string, only
the first row is used
ans = 1

abc = ['a1'; 'a3'; 'a2'];

issorted(abc)
error: issorted: needs a vector

issorted({abc})
warning: multi-row character matrix converted to a string, only
the first row is used
ans = 1

abc = ['a1'; 'b2'; 'a3'];

issorted(abc)
error: issorted: needs a vector

issorted({abc})
warning: multi-row character matrix converted to a string, only
the first row is used
ans = 1

So matlab appears to have no issues checking sorting on a char array, while octave does.  Matlab also appears to look at a char array in a cell as a single unit for sorting, whereas octave sees it as a string array, but then aborts checking for sorting anyway.

Nicholas Jankowski <nrjank>
Project Member

 

(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 mmuetzel (Posted a comment)
  • -email is unavailable- added by nrjank (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-01-10 nrjank Originator NameNicohlas Jankowski Nicholas Jankowski
        Summarymatlab compatibility - issorted array handling matlab compatibility - issorted can't handle arrays
    2022-01-05 nrjank Release7.0.90 dev
        Summarymatlab compatibility - issorted with char arrays matlab compatibility - issorted array handling

    Back to the top


    Powered by Savane 3.9