This project is read-only.


isa() is not checking parents


Octave's implementation of isa() is only checking if the object's class name is the same as one you specified. When one tries to check if the object belongs to the class which is ancestor of the current object class, result is negative.

It means that while Octave's not fixed, +mosw package should be enriched with some Octave specific implementation of isa() which is checking all the ancestors of object's class,

I'm currently using one you may find in attachments.

And occurrences which were needed to be fixed so far are (current stable version may have it at slightly different positions, but it should be close since my clone was recently merged with cset f48289cd75f3):

[file]: /iris_clone/+report/@graphobj/plot.m
     233:             elseif mosw.isa(ch,'report.annotateobj')

[file]: /iris_clone/+report/@modelfileobj/modelfileobj.m
      29:             if ~isempty(varargin) && mosw.isa(varargin{1},'modelobj')

[file]: /iris_clone/classlib/@modelobj/assign.m
      49: elseif n == 1 && mosw.isa(varargin{1},'modelobj')

[file]: /iris_clone/classlib/@modelobj/iscompatible.m
      13:     Flag = mosw.isa(M1,'modelobj') && mosw.isa(M2,'modelobj') ...

[file]: /iris_clone/classlib/@modelobj/subsasgn.m
      75: if ~mosw.isa(This,'modelobj') ...
      76:         || (~mosw.isa(B,'modelobj') && ~isempty(B) && ~isnumeric(B))
     119:     if ~mosw.isa(B,'modelobj') && ~isempty(B)
     127:     if mosw.isa(B,'modelobj') && ~iscompatible(This,B)
     142:     if mosw.isa(B,'modelobj') && ~isempty(B)

[file]: /iris_clone/classlib/@plan/plan.m
     134:                 pp.addRequired('M',@(x) mosw.isa(x,'modelobj'));

[file]: /iris_clone/classlib/@theparser/theparser.m
      39:             if length(varargin) == 1 && mosw.isa(varargin{1},'theparser')
      44:             if length(varargin) == 1 && mosw.isa(varargin{1},'preparser')
      62:                 if length(varargin) >= 2 && mosw.isa(varargin{2},'preparser')

[file]: /iris_clone/dbase/dbminuscontrol.m
      67: pp.addRequired('M',@(x) mosw.isa(x,'modelobj'));

file attachments

Closed Dec 19, 2014 at 4:18 PM by sergeyplotnikov
not an issue anymore


jaromirbenes wrote Jul 17, 2014 at 10:26 PM

Done. The function ismodel tests against both model and modelobj.

sergeyplotnikov wrote Jul 21, 2014 at 4:30 PM

caused no problems

** Closed by sergeyplotnikov 07/21/2014 8:30AM

sergeyplotnikov wrote Sep 18, 2014 at 6:59 PM

I've discovered a few more places where we might need to work this issue around.
[file]: /classlib/@VAR/mycompatible.m
    14:             && isa(V1,'VAR') && isa(V2,'VAR') ...

[file]: /classlib/@svarobj/mycompatible.m
    13:     Flag = isa(V1,'svarobj') && isa(V2,'svarobj');

[file]: /classlib/@varobj/mycompatible.m
    13:     Flag = isa(V1,'varobj') && isa(V2,'varobj') ...

[file]: /classlib/@svarobj/svarobj.m
    16:             if length(varargin) == 1 && isa(varargin{1},'svarobj')

jaromirbenes wrote Oct 2, 2014 at 6:21 PM

Fixed in repo.

sergeyplotnikov wrote Dec 19, 2014 at 3:54 PM

looks like the problem was fixed in new Octave. simple tests are just fine

jaromirbenes wrote Dec 19, 2014 at 4:58 PM

Ok. I'll remove isa(x,'modelobj') from ismodel( ) then.

sergeyplotnikov wrote Dec 19, 2014 at 8:41 PM

shouldn't it be other way round? modelobj is parent of model and ismodel(modelobj_instance) will be false even in Matlab.

jaromirbenes wrote Dec 19, 2014 at 9:23 PM

I meant we separate isa(x,'model') (=ismodel) from isa(x,'modelobj'). Two different tests that can be now treated the same way in Matlab and Octave.

sergeyplotnikov wrote Dec 19, 2014 at 11:51 PM

got it now, and your changeset f6a629938d5d takes care of the rest