bugGNU Octave - Bugs: bug #63104, exist fails to query +package...

 
 

bug #63104: exist fails to query +package functions (such as containers.Map)

Submitter:  Qianqian Fang <fangq>
Submitted:  Sun 25 Sep 2022 04:37:34 PM UTC
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Qianqian Fang Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Tue 22 Nov 2022 06:42:55 PM UTC, comment #2: 

Also, for a class named myClass in a package myPkg, that is, defined in the file +myPkg/myClass.m we have the following with Octave 7.3 on Ubuntu.

exist('myPkg.myClass')

Incorrect. Octave returns 0. MATLAB returns 8.

exist('+myPkg/myClass')

Incorrect. Octave returns 0. MATLAB returns 2.

exist('+myPkg/myClass.m')

Correct. Octave returns 2. MATLAB returns 2.

Ray Zimmerman <rdzman>
Mon 26 Sep 2022 06:55:18 AM UTC, comment #1: 

The `which` function is working for me in Octave 7.2.0. (Octave 5 or 6 are old and no longer supported.)

The `exist` function still returns `0` though.

With Octave 7.2.0 on Windows:

>> which containers.Map
'containers.Map' is a class constructor from the file C:\Program Files\GNU Octave\Octave-7.2.0\mingw64\share\octave\7.2.0\m\+containers\Map.m
>> exist('containers.Map')
ans = 0
>> which('matlab.lang.makeUniqueStrings')
'matlab.lang.makeUniqueStrings' is a function from the file C:\Program Files\GNU Octave\Octave-7.2.0\mingw64\share\octave\7.2.0\m\+matlab\+lang\makeUniqueStrings.m
>> exist('matlab.lang.makeUniqueStrings')
ans = 0

Markus M├╝tzel <mmuetzel>
Project Member
Sun 25 Sep 2022 04:37:34 PM UTC, original submission:  

-------
Summary:

functions stored in a package namespace (+package folder) can not be queried using exist() or which().

This can be reproduced on Octave 5.2 and 6.4. (did not test for 7.x or dev)

-------
Expected result (as in MATLAB):

>> exist('containers.Map')

ans =
     8

>> which containers.Map

containers.Map is a built-in method  % containers.Map constructor

>> which matlab.lang.makeUniqueStrings

/.../MATLAB/R2020a/toolbox/matlab/lang/+matlab/+lang/makeUniqueStrings.m  % static method or package function

>> exist('matlab.lang.makeUniqueStrings.m') %not sure why this happens

ans =
     0

-------
Current result (tested in Octave 6.4.0 on Ubuntu 22.04)
   query failed, but they can be called

>> exist('containers.Map')

ans = 0

>> which containers.Map
>> a=containers.Map()

a =
  containers.Map object with properties:
    Count     : 0
    KeyType   : char
    ValueType : any

>> exist('matlab.lang.makeUniqueStrings')

ans = 0

>> matlab.lang.makeUniqueStrings('test')

ans = test

>> ls '/usr/share/octave/6.4.0/m/+containers/Map.m'

/usr/share/octave/6.4.0/m/+containers/Map.m

>> ls '/usr/share/octave/6.4.0/m/+matlab/+lang/makeUniqueStrings.m'

/usr/share/octave/6.4.0/m/+matlab/+lang/makeUniqueStrings.m

Qianqian Fang <fangq>

 

(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 rdzman (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by fangq (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 project members can vote.

     

     

     

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-09-26 mmuetzel StatusNone Confirmed
        Release6.4.0 dev
        Operating SystemGNU/Linux Any
        Summaryexist and which fail to query +package functions (such as containers.Map) exist fails to query +package functions (such as containers.Map)

    Back to the top


    Powered by Savane 3.9