From: <cde...@us...> - 2010-12-08 17:45:37
|
Revision: 8000 http://octave.svn.sourceforge.net/octave/?rev=8000&view=rev Author: cdemills Date: 2010-12-08 17:45:30 +0000 (Wed, 08 Dec 2010) Log Message: ----------- WIP Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m trunk/octave-forge/extra/dataframe/inst/@dataframe/subsindex.m trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m 2010-12-08 17:08:30 UTC (rev 7999) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m 2010-12-08 17:45:30 UTC (rev 8000) @@ -143,8 +143,10 @@ df._cnt(2), 'column'); else mz = max(cellfun(@length, df._rep)); - [indr, indc, inds] = ind2sub([df._cnt(1:2) mz], indr); - ncol = length(unique(indc)); + [fullindr, fullindc, fullinds] = ind2sub([df._cnt(1:2) mz], indr); + indr = unique(fullindr); indc = unique(fullindc); + inds = unique(fullinds); + ncol = length(indc); S(1).subs{1} = indr; S(1).subs{2} = indc; if (any(inds > 1)), S(1).subs{3} = inds; @@ -481,10 +483,19 @@ %# skip second dim and copy data S.subs(2) = []; Sorig = S; for indi = 1:length(indc), - [df, S] = df_cow(df, S, indc(indi)); + %try + [df, S] = df_cow(df, S, indc(indi)); + # catch + # keyboard + # error(lasterr()); + # end_try_catch if (strcmp(df._type(indc(indi)), RHS._type(indi))), + try df._data{indc(indi)} = feval(@subsasgn, df._data{indc(indi)}, S, \ RHS._data{indi}(:, RHS._rep{indi})); + catch + keyboard + end_try_catch else df._data{indc(indi)} = feval(@subsasgn, df._data{indc(indi)}, S, \ cast(RHS._data{indi}(:, RHS._rep{indi}),\ Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/subsindex.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/subsindex.m 2010-12-08 17:08:30 UTC (rev 7999) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/subsindex.m 2010-12-08 17:45:30 UTC (rev 8000) @@ -37,6 +37,7 @@ dummy = df_whole(df); if isa(dummy, 'logical'), resu = sort(find(dummy)-base); + %# resu = dummy - base; else resu = dummy - base; endif Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m 2010-12-08 17:08:30 UTC (rev 7999) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m 2010-12-08 17:45:30 UTC (rev 8000) @@ -233,11 +233,11 @@ endif else %# one single dim -- probably something like df(:), df(A), ... - fullindr = 1; + fullindr = 1; onedimidx = S(1).subs{1}; switch class(S(1).subs{1}) case {'char'} %# one dimensional access, disallow it if not ':' if (strcmp(S(1).subs{1}, ':')), - fullindr = []; fullindc = []; + fullindr = []; fullindc = []; asked_output_type = "array"; else error(["Accessing through single dimension and name " \ S(1).subs{1} " not allowed\n-- use variable(:, 'name') instead"]); @@ -259,12 +259,9 @@ ([df._cnt dummy], S(1).subs{1}); endif - onedimidx = S(1).subs{1}; - indr = unique(fullindr); nrow = length(indr); %# determine on which columns we'll iterate indc = unique(fullindc)(:).'; ncol = length(indc); - if (!isempty(asked_output_type) && ncol > 1), %# verify that the extracted values form a square matrix dummy = zeros(indr(end), indc(end)); @@ -279,7 +276,6 @@ fullindr = []; fullindc = []; endif endif - endif endif %# at this point, S is either empty, either contains further dereferencing @@ -319,22 +315,24 @@ output_type = "array"; endif endif - + if (any(strcmp({asked_output_type}, class(df)))), %# was (any(strcmp({output_type, asked_output_type}, class(df)))) - if (!isempty(S) && 1 == length(S(1).subs)), - if (ncol > 1), + if (!isempty(S) && (1 == length(S(1).subs))), + if (ncol > 1), if (false & isempty(asked_output_type) \ || strcmp(asked_output_type, class(df))), error("Vector-like access not implemented for 'dataframe' output format"); else [asked_output_type, output_type] = deal("array"); endif -%# error("Selected columns not compatible with cat() -- use 'cell' as output format"); + %# error("Selected columns not compatible with cat() -- use 'cell' as output format"); + elseif ((isnumeric(S(1).subs) && isvector(S(1).subs)) \ + && isempty(asked_output_type)), + %# in the case of vector input, favor array output + [asked_output_type, output_type] = deal("array"); endif endif - elseif (isempty(asked_output_type) && 1 == length(S(1).subs)), - [asked_output_type, output_type] = deal("array"); endif indt = {}; %# in case we have to mix matrix of different width @@ -492,7 +490,7 @@ %# * x(:, :) returns a horzcat of the third dimension %# * x(:, n:m) select only the first sequence %# * x(:) returns a vertcat of the columns of x(:, :) - %# disp('line 403 '); keyboard + disp('line 403 '); keyboard if (isempty(S) || isempty(S(1).subs) || \ length(S(1).subs) > 1 || \ (isnumeric(S(1).subs{1}) && !isvector(S(1).subs{1}))), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |