bugGNU Octave - Bugs: bug #62431, 'format' function inputs and...

 
 

bug #62431: 'format' function inputs and outputs a display state object

Submitter:  Nicholas Jankowski <nrjank>
Submitted:  Mon 09 May 2022 05:37:21 PM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  3 - Low Item Group:  Feature Request
Status:  None Assigned to:  None
Originator Name:  Nicholas Jankowski Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 10 May 2022 08:20:04 PM UTC, comment #1: 

I wouldn't spend too much time on this just now.  Matlab has a history of changing interfaces and R2021a is pretty new and subject to further revision.

For the longest time they had a system where you had to query the root graphics object to find the numeric format.  This seemed so obviously broken that I coded format() to return the current state in output variables.  As is also a Matlab practice, they adopted what Octave has done but with tweaks to make it incompatible.  I further don't understand the fetish with object oriented programming.  There is no real need to have an instance of a dedicated class here when simple variables or a struct would suffice.


Rik <rik5>
Group administrator
Mon 09 May 2022 05:37:21 PM UTC, original submission:  

Another Matlab 2021a change to format, it optionally outputs one argument which is a 'DisplayformatOptions' containing the NumericFormat and LineSpacing properties set by format. calling format with one of these objects as input will set the state to that stored in the object.

compatable behavior could probably be trivially implemented by outputing a struct with the right fields, and setting them accordingly if you get an isstruct on the input arguments. Or slightly better by creating a simple DisplayFormatOptions class overloading format to do the same thing.

But this new output behavior would be incompatable with format's current behavior of outputting the state in 1-3 output variables according to nargout.

see https://www.mathworks.com/help/matlab/ref/format.html

some testing also shows that it permits simultaneous inputs and outputs, storing the previous setting in the output variable, then setting the new state:


>> a = format

a =

  DisplayFormatOptions with properties:

    NumericFormat: "short"
      LineSpacing: "loose"

>> a = format('longe')

a =

  DisplayFormatOptions with properties:

    NumericFormat: "short"
      LineSpacing: "loose"

>> a = format

a =

  DisplayFormatOptions with properties:

    NumericFormat: "longE"
      LineSpacing: "loose"


Nicholas Jankowski <nrjank>
Group 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 rik5 (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 group members can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-05-10 rik5 Priority5 - Normal 3 - Low

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code