bugGNU Octave - Bugs: bug #64003, fields order of inputParser Results

 
 

bug #64003: fields order of inputParser Results

Submitter:  Paul Netsaver <netsaver>
Submitted:  Wed 05 Apr 2023 10:01:36 PM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Netsaver Paul Open/Closed:  * Closed
Release:  * 8.1.0 Operating System:  * Any
Fixed Release:  9.1.0 Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 14 Apr 2023 06:26:57 PM UTC, comment #2: 

Not 100% sure if this is related, but it appears to broke some tests:


 miscellaneous/inputParser.m .................................... pass   27/29
                                                                   FAIL    1
                                                              REGRESSION   1
  ode/odeset.m ................................................... pass    7/9
                                                                   FAIL    2


See also buildbots. E.g.:
https://buildbot.octave.org/#/builders/3/builds/338/steps/7/logs/stdio

Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>
Fri 14 Apr 2023 03:44:37 AM UTC, comment #1: 

It is fairly simple to enforce a sorted order on the Results and Parameters fields.  I made that change here http://hg.savannah.gnu.org/hgweb/octave/rev/a00c7e103041.  This is on the development branch of Octave which will become version 9.1.

Marking as Fixed and closing report.

Rik <rik5>
Group administrator
Wed 05 Apr 2023 10:01:36 PM UTC, original submission:  

It seems that after parsing an input sequence with addOptional and addParameters (here addRequired is not represented), while in Matlab the parameters in the output Results field follow the alphabetical order, in Octave follow the code insertion order:


% defaults = {'a',1,'b',2,'c',3,'z',4}
inputs = {30,'b',20,'a',10}
p = inputParser()
p.addOptional('c',3)
p.addOptional('z',4)
p.addParameter('b',2)
p.addParameter('a',1)
p.parse(inputs{:})
p.Results
% orderfields(p.Results)


Matlab order:

  a = 10
  b = 20
  c = 30
  z = 4


Octave order:

  c = 30
  z = 4
  b = 20
  a = 10


Now, assumed that I prefer Octave solution (it's always possible to sort by alphabetical order, while getting the original one is not possible), I'ld like to know if there is a configuration option for this.
Otherwise, it would be a (minor) misalignment, maybe.
[In my code it generated some errors because the Results output was converted to a cell array and compared with other results. Now I aligned Matlab and Octave's output by explicitly sorting the output by fieldnames].

Regards
Paul Netsaver, Rome



Paul Netsaver <netsaver>

 

(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 dasergatskov (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by netsaver (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 group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-04-14 rik5 Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        StatusNone Fixed
        Open/ClosedOpen Closed
        Operating SystemMicrosoft Windows Any
        Fixed ReleaseNone 9.1.0

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code