octave-maintainers
[Top][All Lists]
Advanced

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

Re: dataframe dereferencing


From: Jaroslav Hajek
Subject: Re: dataframe dereferencing
Date: Thu, 2 Sep 2010 11:22:34 +0200

On Thu, Sep 2, 2010 at 10:35 AM, CdeMills <address@hidden> wrote:
>
> Hello,
>
> Jaroslav pointed me that MatLab disallow accesses with cascaded parenthesis
> a = randn(3, 3)
> a(1:2, 1:2)(:)
>
> I designed my dataframe objects with the ability to specify an output type
> specifier at the end, like
> x(1:3, 1:2)(:).cell. This result is different from
> y = x(1:3, 1:2)(:) <= if types are compatible, y is a matrix
> z = y.cell <= this results in an error
>
> So I modified the code to accept the following syntax:
> x.dataframe; x.df => returns a selection of the dataframe as a dataframe
> object
> x.cell => returns a selection of a dataframe as a cell array with row and
> columns names; this array can be converted back to a dataframe
> x.as.something => returns a selection of a dataframe as a matrix of type
> something. This permits to extract at once columns of different type,
> otherwise the code returns an error. Columns are casted to the type
> 'something'.
> x.as.cell => returns a selection of a dataframe as a cell array without row
> and column names
> x.attributes => return attributes, valid values are 'rownames', 'colnames',
> 'rowcnt', 'rowidx', 'colcnt', ...
> x.colname => return the column with matching name
>
> With this system:
> - chaining rule seems OK to me
> - conversion purpose seems more clear
>
> Comment / advices ? Are there standard rules to dereference objects with the
> '.' operator ?
>
> Regards
>
> Pascal

If you recall my original email from Aug 12:

> Since you can overload subsref virtually arbitrarily, you can make it, say,
> x.dataframe(:, 2)
>
> an alternative is to overload
> x(:,2).dataframe
> but then be sure to overload indexed numel properly (yes and you must
> use Octave 3.3.51+).

I warned you against using the second method, though I probably wasn't
too clear :) I think the first method is also better because it
resembles a C++ method call.

regards

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


reply via email to

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