bugGNU Octave - Bugs: bug #58012, isprop() and fieldnames() not...

 
 

bug #58012: isprop() and fieldnames() not Matlab-compatible for private or hidden properties

Submitter:  None
Submitted:  Thu 19 Mar 2020 07:01:59 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Michael Keller Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 27 Mar 2020 10:08:49 PM UTC, comment #6: 

I pushed a fix to the development branch here: https://hg.savannah.gnu.org/hgweb/octave/rev/47d4a84a5725.

Closing report again as fixed.

Rik <rik5>
Group administrator
Thu 26 Mar 2020 09:54:12 PM UTC, comment #5: 

Oops.  Old-style class objects are rare enough that they didn't get tested.

Test case


octave:1> o = ftp
o =

  FTP object
    host:
    user: anonymous
     dir:
    mode: binary

octave:2> fieldnames (o)
error: invalid class: ftp
error: called from
    fieldnames at line 55 column 11


Re-opening the bug report.

Rik <rik5>
Group administrator
Thu 26 Mar 2020 05:44:00 PM UTC, comment #4: 

The change http://hg.savannah.gnu.org/hgweb/octave/rev/fab3eeb1fc7e breaks fieldnames for non-classdef objects:


octave> fieldnames (oldclassobj)
error: invalid class: oldclassobj
error: called from
    fieldnames at line 55 column 11


Could _fieldnames_ still be used for them if they can be detected as such? Or could properties work for them too?

Guillaume <gyom>
Sun 22 Mar 2020 03:08:22 AM UTC, comment #3: 

I fixed isprop to add support for classdef objects.  See changeset https://hg.savannah.gnu.org/hgweb/octave/rev/925fe981a25c.  This change was done on the development branch and won't be released in Octave until version 7.1 sometime in 2021.  To access it sooner you can download the isprop.m directly from the Mercurial repository.

Marking bug as fixed and closing report.

Rik <rik5>
Group administrator
Sun 22 Mar 2020 03:06:36 AM UTC, comment #2: 

I fixed fieldnames to make use of properties() and only return public properties.  See changeset https://hg.savannah.gnu.org/hgweb/octave/rev/fab3eeb1fc7e.  This change was done on the development branch and won't be released in Octave until version 7.1 sometime in 2021.  To access it sooner you can download the fieldnames.m directly from the Mercurial repository.

Rik <rik5>
Group administrator
Sun 22 Mar 2020 01:31:07 AM UTC, comment #1: 

There is no support for classdef objects in isprop, which is why it always returns false.  It's pretty easy to fix that and I already have a patch for it.

While it may be counter-intuitive, Octave needs to maintain compatibility with Matlab so that code can run repeatably in either environment.  Hence, isprop() needs to return information on all properties, whether they are public, private, or hidden.

You can replace fieldnames() with properties() which will only list the public, non-hidden properties.  However, this will not be available until the 6.1 release (which is currently in process, but with no fixed date).

Rik <rik5>
Group administrator
Thu 19 Mar 2020 07:01:59 PM UTC, original submission:  

Summary of inconsistent behaviour:

1. Bug in varnames()
   Octave reveals both public and private properties of class
2. Bug in isprop()
   Octave shows neither public nor private properties of class

Details:
In my opinion varnames() and isprop() should both show public properties if applied to a class. Private properties should not be shown.

Both functions give different results and to me both seem wrong.
The behaviour is also different from Matlab.

It's two functions so it should probably be two bugs? But i think it's important that they should behave the same way.

The attached script and 2 classes show the issue in detail.

Strange enough Matlab behaves different in derived class which seems a Bug in Matlab (I will file that to Mathworks ;)

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #48627:  demoScript.m added by None (2KiB - application/vnd.wolfram.mathematica.package - demoScript contains detailed description of expected behaviour)
file #48628:  myDerivedClass.m added by None (191B - application/vnd.wolfram.mathematica.package - demoScript contains detailed description of expected behaviour)
file #48629:  myClass.m added by None (290B - application/vnd.wolfram.mathematica.package - demoScript contains detailed description of expected behaviour)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gyom (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (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 14 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-03-27 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2020-03-26 rik5 StatusFixed Confirmed
        Open/ClosedClosed Open
    2020-03-22 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2020-03-22 rik5 Item GroupIncorrect Result Matlab Compatibility
        StatusNone Confirmed
        Release5.2.0 dev
        Operating SystemMicrosoft Windows Any
        Summaryinconsistend public vs private variable handling isprop() and fieldnames() not Matlab-compatible for private or hidden properties
    2020-03-19 None Attached File- Added demoScript.m, #48627
        Attached File- Added myDerivedClass.m, #48628
        Attached File- Added myClass.m, #48629

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code