method indexing bug

View: New views
8 Messages — Rating Filter:   Alert me  

method indexing bug

by David Grundberg-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi bug-list,

In an object's subasgn, I want to assign to a object field using

  object.field(1, :) = [1,2]

syntax. This works in Matlab. However, in Octave, I get 'error: a
cs-list cannot be further indexed'.

I'm attaching a tarball with an example as minimal as I could make it.
After extracting the tarball, I can run

  p=Mini; p.key = 1:2

on rev 9771:4634a0e9ea1b to recreate the error message.

Regards,
David



_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: method indexing bug

by David Grundberg-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David Grundberg wrote:

> Hi bug-list,
>
> In an object's subasgn, I want to assign to a object field using
>
>   object.field(1, :) = [1,2]
>
> syntax. This works in Matlab. However, in Octave, I get 'error: a
> cs-list cannot be further indexed'.
>
> I'm attaching a tarball with an example as minimal as I could make it.
> After extracting the tarball, I can run
>
>   p=Mini; p.key = 1:2
>
> on rev 9771:4634a0e9ea1b to recreate the error message.
>
> Regards,
> David
>  
Naturally, it helps if I actually attach the tarball.



_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Mini.tar.gz (808 bytes) Download Attachment

Re: method indexing bug

by Jaroslav Hajek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Nov 3, 2009 at 3:08 PM, David Grundberg <individ@...> wrote:

> David Grundberg wrote:
>>
>> Hi bug-list,
>>
>> In an object's subasgn, I want to assign to a object field using
>>
>>  object.field(1, :) = [1,2]
>>
>> syntax. This works in Matlab. However, in Octave, I get 'error: a cs-list
>> cannot be further indexed'.
>>
>> I'm attaching a tarball with an example as minimal as I could make it.
>> After extracting the tarball, I can run
>>
>>  p=Mini; p.key = 1:2
>>
>> on rev 9771:4634a0e9ea1b to recreate the error message.
>>
>> Regards,
>> David
>>
>
> Naturally, it helps if I actually attach the tarball.
>
>

Please try this patch:
http://hg.savannah.gnu.org/hgweb/octave/rev/384616240a8f

thanks

--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: method indexing bug

by David Grundberg-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jaroslav Hajek wrote:

> On Tue, Nov 3, 2009 at 3:08 PM, David Grundberg <individ@...> wrote:
>  
>> David Grundberg wrote:
>>    
>>> Hi bug-list,
>>>
>>> In an object's subasgn, I want to assign to a object field using
>>>
>>>  object.field(1, :) = [1,2]
>>>
>>> syntax. This works in Matlab. However, in Octave, I get 'error: a cs-list
>>> cannot be further indexed'.
>>>
>>> I'm attaching a tarball with an example as minimal as I could make it.
>>> After extracting the tarball, I can run
>>>
>>>  p=Mini; p.key = 1:2
>>>
>>> on rev 9771:4634a0e9ea1b to recreate the error message.
>>>
>>> Regards,
>>> David
>>>
>>>      
>> Naturally, it helps if I actually attach the tarball.
>>
>>
>>    
>
> Please try this patch:
> http://hg.savannah.gnu.org/hgweb/octave/rev/384616240a8f
>
> thanks
>
>  


Jaroslav,

thanks for fixing this. The indexing works now.

David
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: method indexing bug

by Jaroslav Hajek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Tue, Nov 10, 2009 at 12:04 PM, David Grundberg <individ@...> wrote:
Jaroslav Hajek wrote:
On Tue, Nov 3, 2009 at 3:08 PM, David Grundberg <individ@...> wrote:
 
David Grundberg wrote:
   
Hi bug-list,

In an object's subasgn, I want to assign to a object field using

 object.field(1, :) = [1,2]

syntax. This works in Matlab. However, in Octave, I get 'error: a cs-list
cannot be further indexed'.

I'm attaching a tarball with an example as minimal as I could make it.
After extracting the tarball, I can run

 p=Mini; p.key = 1:2

on rev 9771:4634a0e9ea1b to recreate the error message.

Regards,
David

     
Naturally, it helps if I actually attach the tarball.


   

Please try this patch:
http://hg.savannah.gnu.org/hgweb/octave/rev/384616240a8f

thanks

 


Jaroslav,

thanks for fixing this. The indexing works now.

David

Good. Please note that the OOP support is still partial; inheritance simply doesn't work together with multidimensional classes. To make it work like in Matlab a massive rewrite would probably be needed.

--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: method indexing bug

by John W. Eaton-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10-Nov-2009, Jaroslav Hajek wrote:

| Good. Please note that the OOP support is still partial; inheritance simply
| doesn't work together with multidimensional classes. To make it work like in
| Matlab a massive rewrite would probably be needed.

By multidimensional classes, do you mean something like

  class (struct ("x", {1, 2; 3, 4}), "foo")

?  Is this kind of thing used very often by real code?  How is it
useful?

jwe

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: method indexing bug

by David Grundberg-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jaroslav Hajek wrote:

>
>
> On Tue, Nov 10, 2009 at 12:04 PM, David Grundberg <individ@...
> <mailto:individ@...>> wrote:
>
>     Jaroslav Hajek wrote:
>
>         On Tue, Nov 3, 2009 at 3:08 PM, David Grundberg
>         <individ@... <mailto:individ@...>> wrote:
>          
>
>             David Grundberg wrote:
>                
>
>                 Hi bug-list,
>
>                 In an object's subasgn, I want to assign to a object
>                 field using
>
>                  object.field(1, :) = [1,2]
>
>                 syntax. This works in Matlab. However, in Octave, I
>                 get 'error: a cs-list
>                 cannot be further indexed'.
>
>                 I'm attaching a tarball with an example as minimal as
>                 I could make it.
>                 After extracting the tarball, I can run
>
>                  p=Mini; p.key = 1:2
>
>                 on rev 9771:4634a0e9ea1b to recreate the error message.
>
>                 Regards,
>                 David
>
>                      
>
>             Naturally, it helps if I actually attach the tarball.
>
>
>                
>
>
>         Please try this patch:
>         http://hg.savannah.gnu.org/hgweb/octave/rev/384616240a8f
>
>         thanks
>
>          
>
>
>
>     Jaroslav,
>
>     thanks for fixing this. The indexing works now.
>
>     David
>
>
> Good. Please note that the OOP support is still partial; inheritance
> simply doesn't work together with multidimensional classes. To make it
> work like in Matlab a massive rewrite would probably be needed.

Ok, good to know about problems with multidimensional classes.
Fortunate, I don't have any inheritance!

One problem with making a Matlab-compatible oo system is that OOP is
extremely scarcely documented. The docs are written by some technical
writer that haven't bothered to test whether the statements made are
correct. The new oo-system (with single classdef files) makes it even
harder to know how the legacy system is supposed to work.

Does anyone have a detailed idea of how legacy OOP works in Matlab?
Otherwise implementing it correctly would be hard.

David

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: method indexing bug

by Jaroslav Hajek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Tue, Nov 10, 2009 at 1:10 PM, John W. Eaton <jwe@...> wrote:
On 10-Nov-2009, Jaroslav Hajek wrote:

| Good. Please note that the OOP support is still partial; inheritance simply
| doesn't work together with multidimensional classes. To make it work like in
| Matlab a massive rewrite would probably be needed.

By multidimensional classes, do you mean something like

 class (struct ("x", {1, 2; 3, 4}), "foo")

?  

Yes.
 
Is this kind of thing used very often by real code?  How is it
useful?

jwe


I dunno. I suppose scalar struct with multidimensional fields will be used in most cases - that gives you a far better flexibility
(an example is the dict class from the "general" package).
What Matlab does in the multi-dim inheritance case is also quite weird. When you create

obj = class (struct ("x", {1, 2; 3, 4}), "foo", bar),

I think bar may either be a scalar or 2x2. obj.bar then behaves like an ordinary field, i.e. gives a cs-list of 4 bar classes. Stuff like obj(I,J).bar also works. This would suggest that the constructor splits bar into 1x1 inherited sub objects (or replicates the 1x1 object given) and stores the field normally.
But then, when foo object is passed to an inherited method, a 2x2 class is visible again to the method, as if the 1x1 objects were magically joined. I tested this quickly with a Matlab copy some time ago, so I may not be entirely correct here.

In any case this behaviour is quite ill-suited for our current implementation - splitting a struct array into scalar structs is very wasteful, and this is needed for an ordinary field to be created. If we were to work this around, then foo.bar must not be an ordinary field, but resolved magically.

--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave