bugGNU Octave - Bugs: bug #42510, methods() does not return...

 
 

bug #42510: methods() does not return functions defined in classdef file

Submitted by:  Rik <rik5>
Submitted on:  Thu 05 Jun 2014 03:41:02 AM UTC  
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Fri 08 Mar 2019 12:03:35 AM UTC, comment #17: 

Sure, this can be closed.  I think we need a separate bug report about methods returning functions even when the attribute Hidden is true.

I have a question to the Octave Maintainers mailing list about this same issue with properties().

When this is resolved, I think the right answer may be to add a new method to the C++ cdef_property class named is_hidden() which is analogous to is_constant().  It seems like it needs to be checked frequently.

Rik <rik5>
Project Administrator
Thu 07 Mar 2019 11:29:08 PM UTC, comment #16: 

There's been a lot of good work done here, but more issues have been raised in the process. I think this bug could be marked fixed since methods are returned now, and any remaining issues can be tracked separately.

Mike Miller <mtmiller>
Project Administrator
Fri 22 Feb 2019 06:03:27 PM UTC, comment #15: 

The package name is not included in the constructor name in the output, for either classdef classes or Java classes. methods('java.lang.String') lists 'String' as the method name, just as methods('containers.Map') lists 'Map' as the method name. I have no idea why methods('MException') doesn't list 'MException', must be a weird quirk of the implementation.

Mike Miller <mtmiller>
Project Administrator
Fri 22 Feb 2019 05:43:38 PM UTC, comment #14: 

Per testing, Matlab seems to return only Public methods which are also not Hidden.  All others (Private, Protected) are not shown even with '-full'.

There is a similar issue with properties and the Hidden attribute for which I will file a new bug report.

Rik <rik5>
Project Administrator
Fri 22 Feb 2019 04:34:18 PM UTC, comment #13: 

I posted some sample code and the question about visibility on the Octave Maintainer's list.

Rik <rik5>
Project Administrator
Fri 22 Feb 2019 07:48:38 AM UTC, comment #12: 

Oh, I see, I was scanning the list looking for java.lang.String, not just String.  For classdef classes, is it a matter of visibility?  The docs here say hidden methods don't show up in the list:

https://www.mathworks.com/help/matlab/matlab_oop/method-attributes.html

John W. Eaton <jwe>
Project Administrator
Fri 22 Feb 2019 04:56:21 AM UTC, comment #11: 

> What happens when nargout > 0 and the output goes to a cell array?


All methods are listed together sorted by name:

>> x = methods('MException')

x = 9×1 cell array
    {'addCause'     }
    {'eq'           }
    {'getReport'    }
    {'isequal'      }
    {'last'         }
    {'ne'           }
    {'rethrow'      }
    {'throw'        }
    {'throwAsCaller'}

Mike Miller <mtmiller>
Project Administrator
Fri 22 Feb 2019 04:45:32 AM UTC, comment #10: 

That is pretty confusing. The output for methods('MException') does not list 'MException', but the output for methods('inputParser') does include 'inputParser'. What's the difference?

Constructors should also be listed for Java classes, for example the output for methods('java.lang.String') on that page shows 'String' at the front of the list. And for methods('java.lang.String', '-full') it should list all constructor overloads.

Mike Miller <mtmiller>
Project Administrator
Fri 22 Feb 2019 04:32:46 AM UTC, comment #9: 

I don't see the constructor names in the output shown in the examples on this page:

https://www.mathworks.com/help/matlab/ref/methods.html

but I do see that static methods are listed separately, at least when the output is displayed.  What happens when nargout > 0 and the output goes to a cell array?

John W. Eaton <jwe>
Project Administrator
Fri 22 Feb 2019 01:18:50 AM UTC, comment #8: 

I notice that Matlab returns the constructor along with the other methods for both Java objects and classdef objects.  For example,

x = methods ('inputParser');
any (strcmp (x, 'inputParser'))

Also, when using '-full', the list of methods is returned sorted in Matlab.  That would probably be nice because otherwise it can be just a real jumble.

Rik <rik5>
Project Administrator
Fri 22 Feb 2019 01:09:41 AM UTC, comment #7: 

Not huge, but I changed methods to return a column vector for Java objects for Matlab compatibility (https://hg.savannah.gnu.org/hgweb/octave/rev/3cbc3c741f81).

Rik <rik5>
Project Administrator
Fri 22 Feb 2019 01:08:40 AM UTC, comment #6: 

I added documentation about the '-full' option here (https://hg.savannah.gnu.org/hgweb/octave/rev/ebf5ef76f56e).

Rik <rik5>
Project Administrator
Thu 21 Feb 2019 11:30:08 PM UTC, comment #5: 

I changed the regular expression used to find function names from signatures slightly (https://hg.savannah.gnu.org/hgweb/octave/rev/c1d5a0a799b2) so that signatures with spaces, such as "unsigned int" are handled correctly.

Rik <rik5>
Project Administrator
Thu 21 Feb 2019 06:48:44 PM UTC, comment #4: 

We can keep the discussion here.  I pushed the following changeset so that methods recognizes the "-full" option and only lists the signatures if that option is used:

http://hg.savannah.gnu.org/hgweb/octave/rev/8554becefe1b

That should also fix ismethod for Java methods, I think.

If you think that's sufficient for now, then we can close this report.

John W. Eaton <jwe>
Project Administrator
Thu 21 Feb 2019 04:58:53 PM UTC, comment #3: 

@jwe: Do you want to close this report and open up a new one about eliminating duplicates and type information (for example from Java class objects) or keep working with this report?

Rik <rik5>
Project Administrator
Sat 16 Feb 2019 10:55:23 PM UTC, comment #2: 

Ho ho ho. Looking good.

>> ver
----------------------------------------------------------------------
GNU Octave Version: 6.0.0 (hg id: f85d491d2322 + patches)
GNU Octave License: GNU General Public License
Operating System: Darwin 17.7.0 Darwin Kernel Version 17.7.0: Thu Dec 20 21:47:19 PST 2018; root:xnu-4570.71.22~1/RELEASE_X86_64 x86_64
----------------------------------------------------------------------
Package Name   | Version | Installation directory
---------------+---------+-----------------------
      control  |   3.1.0 | /Users/janke/octave/control-3.1.0
generate_html  |   0.3.1 | /Users/janke/octave/generate_html-0.3.1
           io  |  2.4.12 | /Users/janke/octave/io-2.4.12
>> cd ~/local/repos/octave-chrono/inst
>> methods datetime
Methods for class datetime:
NaT                     dispstrs                isrow                   plus                    subsasgnParensPlanar
asgn                    eq                      isscalar                posix2datenum           subset
cat                     ge                      isvector                promote                 subsref
circshift               gt                      le                      promotec                subsrefParensPlanar
colon                   hms                     linspace                proxyKeys               timeofday
convertDatenumTimeZone  horzcat                 lt                      quarter                 transpose
ctranspose              hour                    minus                   repmat                  union
datenum2posix           intersect               minute                  reshape                 unique
datestr                 ipermute                month                   second                  vertcat
datestrs                isbetween               ndims                   setdiff                 week
datestruct              iscolumn                ne                      shiftdim                year
datestruct2datenum      isempty                 numel                   size                    ymd
day                     ismatrix                ofDatenum               sort                    ymdhms
diff                    ismember                ofDatestruct            sortND
disp                    isnan                   parensRef               squeeze
display                 isnat                   permute                 subsasgn

>> m = methods('datetime')
m =
{
  [1,1] = NaT
  [2,1] = asgn
[...]

Andrew Janke <apjanke>
Tue 12 Feb 2019 09:28:40 PM UTC, comment #1: 
John W. Eaton <jwe>
Project Administrator
Thu 05 Jun 2014 03:41:02 AM UTC, original submission:  

The methods() function when called on a classdef object should return the methods of the class.  Currently this only works for functions which are defined in separate files under the directory @classname.  It does not work for methods which are defined within the class itself.

Rik <rik5>
Project Administrator

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by apjanke (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by apjanke (Adding self to Cc list)
  • -email is unavailable- added by amro_octave
  • -email is unavailable- added by rik5 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-10 rik5 StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2019-02-12 jwe StatusNone => Ready For Test
    2019-01-14 apjanke Carbon-Copy- => Added floss@apjanke.net
    2016-12-09 amro_octave Carbon-Copy- => Added amro_octave
    2015-03-20 jordigh Dependencies- => Depends on bugs #44590
    2014-06-05 rik5 Summarymethods does not return functions defined in classdef file => methods() does not return functions defined in classdef file

    Back to the top


    Powered by Savane 3.5