octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #64003] fields order of inputParser Results


From: Paul Netsaver
Subject: [Octave-bug-tracker] [bug #64003] fields order of inputParser Results
Date: Wed, 5 Apr 2023 18:01:39 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?64003>

                 Summary: fields order of inputParser Results
                   Group: GNU Octave
               Submitter: netsaver
               Submitted: Wed 05 Apr 2023 10:01:36 PM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Netsaver Paul
        Originator Email: 
             Open/Closed: Open
                 Release: 8.1.0
         Discussion Lock: Any
        Operating System: Microsoft Windows
           Fixed Release: None
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Wed 05 Apr 2023 10:01:36 PM UTC By: Paul Netsaver <netsaver>
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










    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64003>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]