octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Class related regressions in GNU Octave 4.0


From: Julien Bect
Subject: Re: Class related regressions in GNU Octave 4.0
Date: Mon, 13 Apr 2015 07:39:02 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

Le 12/04/2015 21:08, Mike Miller a écrit :
One thing that I think is missing from this discussion and your examples is how are the isempty, numel, ndims, and length functions expected to work with these types of classes?

All of these can be overriden for user-defined classes.

I am pretty sure that, in Matlab, the *builtin* isempty, ndims and length use the (possibly overriden) result of size, which means that it is not necessary to override them if you want to get the usual behaviour.

numel can be overriden too, but it is a different kind of beast, because it is used (again, in Matlab) to determine the length of the comma-separated list obtained as the result of x.fieldname.

The stk_dataframe class in the stk package provides an example of an array-like class where size is overriden to behave as usual (returns the size of the underlying array) whereas numel is not overriden and therefore returns 1 (which is the size of {x.propname} where propname is any property name supported in subsref).

HTH,

Julien


PS : a class like the dataframe class from Octave's dataframe package could not work in Matlab, because of this

pkg load dataframe
data = dataframe (rand (4, 2))
{data.X1}                 # 1x1 cell
numel (data)             # = 8, should be 1, given the preceding line




reply via email to

[Prev in Thread] Current Thread [Next in Thread]