From: <cde...@us...> - 2010-12-04 22:04:41
|
Revision: 7980 http://octave.svn.sourceforge.net/octave/?rev=7980&view=rev Author: cdemills Date: 2010-12-04 22:04:35 +0000 (Sat, 04 Dec 2010) Log Message: ----------- Sorted an issue with assignement Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2010-12-03 17:45:31 UTC (rev 7979) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2010-12-04 22:04:35 UTC (rev 7980) @@ -313,6 +313,7 @@ endif endif if (!isempty(indj)), + %# the exact row size will be determined latter idx.subs = {'', indj}; %# use direct assignement if (ndims(x) > 2), idx.subs{3} = 1:size(x, 3); endif Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m 2010-12-03 17:45:31 UTC (rev 7979) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m 2010-12-04 22:04:35 UTC (rev 7980) @@ -51,15 +51,16 @@ dummy = find(dummy == indi); df._rep{col}(dummy) = t1; endif - if (length(S.subs) > 1 && indi > 1), - %# adapt the sheet index accordingly - keyboard - S.subs{2}(find(S.subs{2}==indi)) = t1; - endif - endfor endfor - + %# reorder S + if (length(S.subs) > 1), + dummy = length(S.subs{2}); + if (dummy > 1), + %# the second factor is a permutation matrix + S.subs{2} = S.subs{2}*(eye(dummy)(:, df._rep{col})); + endif + endif %# sanity check dummy = sum(cellfun(@length, df._rep)); if dummy != df._cnt(2), Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m 2010-12-03 17:45:31 UTC (rev 7979) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m 2010-12-04 22:04:35 UTC (rev 7980) @@ -143,17 +143,13 @@ df._cnt(2), 'column'); else mz = max(cellfun(@length, df._rep)); -before = S(1).subs{1}; [indr, indc, inds] = ind2sub([df._cnt(1:2) mz], indr); ncol = length(unique(indc)); S(1).subs{1} = indr; S(1).subs{2} = indc; if (any(inds > 1)), S(1).subs{3} = inds; endif - toto=df_whole(df); - keyboard endif - keyboard resu = df_matassign(df, S, indc, ncol, RHS); endswitch @@ -466,7 +462,6 @@ endfor else - keyboard %# RHS is either a numeric, either a df if (any(indc > min(size(df._data, 2), df._cnt(2)))), df = df_pad(df, 2, max(indc-min(size(df._data, 2), df._cnt(2))),\ @@ -547,7 +542,7 @@ fillfunc = @(x, S, y) feval(@subsasgn, x, S, RHS); endif endif - Sorig = S; keyboard + Sorig = S; for indi = 1:length(indc), try [df, S] = df_cow(df, S, indc(indi), inds); @@ -569,24 +564,16 @@ # end_try_catch endfor else %# 2D - 3D matrix - disp('line 572 '); keyboard S.subs(2) = []; %# ignore 'column' dimension - %# rotate slices in dim 1-3 to slices in dim 1-2 if (isempty(S.subs{1})), - fillfunc = @(x, S, y) squeeze(RHS(:, y, :)); - else - fillfunc = @(x, S, y) feval(@subsasgn, x, S, squeeze(RHS(:, y, :))); + S.subs{1} = indr; endif + %# rotate slices in dim 1-3 to slices in dim 1-2 + fillfunc = @(x, S, y) feval(@subsasgn, x, S, squeeze(RHS(:, y, :))); Sorig = S; for indi = 1:length(indc), - disp('line 582 '); disp(df._rep); disp(S); keyboard [df, S] = df_cow(df, S, indc(indi), inds); - disp('line 584 '); disp(df._rep);disp(S); keyboard df._data{indc(indi)} = fillfunc(df._data{indc(indi)}, S, indi); - disp('line 586 '); disp(df._rep); - disp(squeeze(RHS(:, indc(indi), :))); - disp(df._data{indc(indi)}(:, df._rep{indc(indi)})); - keyboard S = Sorig; endfor endif @@ -600,7 +587,6 @@ if !isempty(indr) && isnumeric(indr), if max(indr) > df._cnt(1) && size(df._data, 2) < df._cnt(2), df = df_pad(df, 1, max(indr)-df._cnt(1), rname_width); - keyboard endif endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |