bugGNU Octave - Bugs: bug #55983, 'x(ix) = []' deletion syntax does...


bug #55983: 'x(ix) = []' deletion syntax does not work for objects

Submitted by:  Andrew Janke <apjanke>
Submitted on:  Fri 22 Mar 2019 11:38:37 PM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  5.1.0 Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

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


Sun 24 Mar 2019 03:51:53 PM UTC, comment #4:

> MyDumbClass has no subsasgn: isn't that involved in making this work?

It shouldn't be. There should be a default implementation that works like it does for structs. Overriding subsasgn and related methods should only be necessary if you have a custom internal array representation, for example, if you're writing a planar-organized object.

Andrew Janke <apjanke>
Sun 24 Mar 2019 03:14:15 PM UTC, comment #3:

MyDumbClass has no subsasgn: isn't that involved in making this work?  I definitely had to implement this operation myself in `@sym`.

Colin Macdonald <cbm>
Sat 23 Mar 2019 04:25:26 AM UTC, comment #2:

> 2. How do you know its not a problem with your `packajoozle` class?

The PkgVer class is very simple. But, valid question.

Here's a simpler reproduction case. I have a MyDumbClass.m, the entirety of which is this:

classdef MyDumbClass

    x = 42;


Same behavior:

>> x = MyDumbClass
x =
<object MyDumbClass>

>> xx = x;
>> xx(2) = x;
>> xx(3) = x;
>> xx(2) = []
error: cannot convert `null_matrix' into `object'

Andrew Janke <apjanke>
Sat 23 Mar 2019 12:38:59 AM UTC, comment #1:

Interestingly, this does work with Symbolic using old style @class:

>> syms x
>> A = [x 2*x 3*x]
A = (sym) [x  2⋅x  3⋅x]  (1×3 matrix)
>> A(2) = []
A = (sym) [x  3⋅x]  (1×2 matrix)

1.  I don't remember this regressing when we tried to port Symbolic to classdef (https://github.com/cbm755/octsympy/pull/590)

2.  How do you know its not a problem with your `packajoozle` class?

3.  IIRC, there were some subtle differences between Octave and Matlab: how to make this work might've been one of them...

Colin Macdonald <cbm>
Fri 22 Mar 2019 11:38:37 PM UTC, original submission:

The special 'x(ix) = []' syntax is supposed to remove identified elements from the array x, regardless of x's type. That is, [] may be a double, but it doesn't matter whether x's type is assignment-compatible with double for this special calling form.

This doesn't work for classdef objects. For example:

octave:1> addpath('~/local/repos/octave-packajoozle/inst')
octave:2> pkg = packajoozle.internal.PkgVer ('financial', '0.5.3')
pkg =
financial 0.5.3

octave:3> p = pkg;
octave:4> p(2) = pkg;
octave:5> p(3) = pkg
p =
financial 0.5.3; financial 0.5.3; financial 0.5.3

octave:6> p(2) = []
error: cannot convert `null_matrix' into `object'

Andrew Janke <apjanke>


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

Attach Files:

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 cbm (Posted a comment)
  • -email is unavailable- added by apjanke (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.




    No changes have been made to this item

    Back to the top

    Powered by Savane 3.4