bugGNU Octave - Bugs: bug #33062, resize and reshape used with...

 
 

bug #33062: resize and reshape used with objects return structures

Submitter:  None
Submitted:  Wed 13 Apr 2011 12:29:29 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  dbateman
Originator Name:  David Bateman Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.4.0
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 19 Apr 2011 12:39:01 AM UTC, comment #4: 

Applied to stable in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/3b2e005e4219)

Rik <rik5>
Group administrator
Sun 17 Apr 2011 06:40:34 PM UTC, comment #3: 

The size is calculated as the number of elements multiplied by the size of the element. This is true for all Octave data types, so I don't find that a 1x0 object occupies O bytes as given by "whos" as surprising.

As for the second issue; The fact that you can resize or reshape the object doesn't mean that the methods of the class have to make sense of the objects that are reshaped. I picked the "ftp" class as the only class that is included with Octave itself, and that makes demonstrating the issue easiest. Unfortunately the methods of the ftp class can only had 1x1 objects as you found out. I was aware of this when I submitted the bug report, but went with the convenience of using he "ftp" class to demonstrate the issue.

Its easy to create a test class that demonstrates the issue with a class that can handle MxN objects, for example the MTEX package was several of them.
D.

David Bateman <dbateman>
Group Member
Thu 14 Apr 2011 11:39:23 PM UTC, comment #2: 

While testing your patch I ran into some issues.  See below:


octave:1> a = resize (ftp('ftp.octave.org'), 1, 0);
octave:2> whos a
Variables in the current scope:

  Attr Name        Size                     Bytes  Class
  ==== ====        ====                     =====  =====
       a           1x0                          0  struct

Total is 0 elements using 0 bytes

octave:3> b = ftp('ftp.octave.org')
octave:4> whos b
Variables in the current scope:

  Attr Name        Size                     Bytes  Class
  ==== ====        ====                     =====  =====
       b           1x1                         38  ftp

Total is 1 element using 38 bytes


Is 'a' really supposed to occupy 0 bytes?

Also, the instance 'a' does not work whereas instance 'b' does.

dir (a)
error: __ftp_dir__: incorrect number of arguments
error: called from:
error:   /home/rik/wip/Projects_Mine/octave-doc/scripts/@ftp/dir.m at line 27, column 5

dir (b)
d--x--x--x    2 0        0            4096 Sep 23  2007 bin
d--x--x--x    2 0        0            4096 Dec 09  2005 dev
d--x--x--x    2 0        0            4096 Dec 09  2005 etc
d--x--x--x    2 0        0            4096 Sep 23  2007 lib
drwxr-xr-x    9 0        0            4096 Nov 20  2008 pub


Rik <rik5>
Group administrator
Wed 13 Apr 2011 02:15:22 PM UTC, comment #1: 

As I don't have access to my development (including the tree I can check in form), could someone commit the attached changest and I close this bug

David


(file #23233)

David Bateman <dbateman>
Group Member
Wed 13 Apr 2011 12:29:29 PM UTC, original submission:  

Consider the code

a = resize (ftp('ftp.octave.org'), 1, 0);
whos a

This returns a structure rather than a class of the type "ftp". A similar result is obtained with the resize function. I propose the patch attached

D.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #23233:  changeset added by dbateman (2KiB - application/octet-stream)
file #23232:  patch added by None (816B - application/octet-stream)

 

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 dbateman (Updated the item)
  • -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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-04-19 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2011-04-13 dbateman Attached File- Added changeset, #23233
        StatusNone Patch Submitted
        Assigned toNone dbateman
    2011-04-13 None Attached File- Added patch, #23232

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code