From: <cde...@us...> - 2010-12-05 12:22:09
|
Revision: 7981 http://octave.svn.sourceforge.net/octave/?rev=7981&view=rev Author: cdemills Date: 2010-12-05 12:22:03 +0000 (Sun, 05 Dec 2010) Log Message: ----------- Fixed some other issues with 3D access Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m 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-04 22:04:35 UTC (rev 7980) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m 2010-12-05 12:22:03 UTC (rev 7981) @@ -1,6 +1,6 @@ -function [df, S] = df_cow(df, S, col, inds) +function [df, S] = df_cow(df, S, col) - %# function [resu, S] = df_cow(df, S, col, inds) + %# function [resu, S] = df_cow(df, S, col) %# Implements Copy-On-Write on dataframe. If one or more columns %# specified in inds is aliased to another one, duplicate it and %# adjust the repetition index to remove the aliasing @@ -33,7 +33,12 @@ error("df_cow must work on a column-by-column basis"); endif - if isempty(inds), inds = 1; endif + if (1 == length(S.subs)), + inds = 1; + else + inds = S.subs{2}; + endif + for indi = inds, dummy = df._rep{col}; dummy(indi) = 0; [t1, t2] = ismember(df._rep{col}(indi)(:), dummy); @@ -53,12 +58,12 @@ 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})); + if (S.subs{2} != 1 || length(S.subs{2}) > 1), + %# adapt sheet index according to df_rep + S.subs{2} = df._rep{col}(S.subs{2}); endif endif %# sanity check Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m 2010-12-04 22:04:35 UTC (rev 7980) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m 2010-12-05 12:22:03 UTC (rev 7981) @@ -479,33 +479,22 @@ if (isa(RHS, 'dataframe')), %# block-copy index S.subs(2) = 1; - df._ridx = feval(@subsasgn, df._ridx, S, RHS._ridx); + if any(!isna(RHS._ridx)), + df._ridx = feval(@subsasgn, df._ridx, S, RHS._ridx); + endif %# skip second dim and copy data - S.subs(2) = []; + S.subs(2) = []; Sorig = S; for indi = 1:length(indc), - if (1 == length(RHS._rep{indi})), - df = df_cow(df, S, indc(indi), inds); - if (strcmp(df._type(indc(indi)), \ - RHS._type(indi))), - df._data{indc(indi)}(indr, 1) = RHS._data{indi}; - else - df._data{indc(indi)}(indr, 1) = cast(RHS._data{indi}, \ - df._type(indc(indi))); - endif + [df, S] = df_cow(df, S, indc(indi)); + if (strcmp(df._type(indc(indi)), RHS._type(indi))), + df._data{indc(indi)} = feval(@subsasgn, df._data{indc(indi)}, S, \ + RHS._data{indi}(:, RHS._rep{indi})); else - unfolded = df._data{indc(indi)}(:, df._rep{indc(indi)}); - if (strcmp(df._type(indc(indi)), RHS._type(indi))), - truc = RHS._data{indi}(:, RHS._rep{indi}); - unfolded = feval(@subsasgn, unfolded, S, \ - RHS._data{indi}(:, RHS._rep{indi})); - else - unfolded = feval(@subsasgn, unfolded, S, \ - cast(RHS._data{indi}(:, RHS._rep{indi}), \ - df._type(indc(indi)))); - endif - df._data{indc(indi)} = unfolded; - df._rep{indc(indi)} = 1:size(unfolded, 2); + df._data{indc(indi)} = feval(@subsasgn, df._data{indc(indi)}, S, \ + cast(RHS._data{indi}(:, RHS._rep{indi}),\ + df._type(indc(indi)))); endif + S = Sorig; endfor if (!isempty(RHS._name{1})), df._name{1}(indr) = RHS._name{1}(indr); @@ -545,7 +534,7 @@ Sorig = S; for indi = 1:length(indc), try - [df, S] = df_cow(df, S, indc(indi), inds); + [df, S] = df_cow(df, S, indc(indi)); df._data{indc(indi)} = fillfunc(df._data{indc(indi)}, S, indi); S = Sorig; catch @@ -572,7 +561,7 @@ fillfunc = @(x, S, y) feval(@subsasgn, x, S, squeeze(RHS(:, y, :))); Sorig = S; for indi = 1:length(indc), - [df, S] = df_cow(df, S, indc(indi), inds); + [df, S] = df_cow(df, S, indc(indi)); df._data{indc(indi)} = fillfunc(df._data{indc(indi)}, S, indi); S = Sorig; endfor Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m 2010-12-04 22:04:35 UTC (rev 7980) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m 2010-12-05 12:22:03 UTC (rev 7981) @@ -348,8 +348,8 @@ resu._cnt(1) = nrow; resu._cnt(2) = ncol; for indi = 1:ncol, resu._data{indi} = df._data{indc(indi)}\ - (indr, indt{indc(indi)}); - resu._rep{indi} = df._rep{indc(indi)}(indt{indc(indi)}); + (indr, df._rep{indi}(indt{indc(indi)})); + resu._rep{indi} = 1:size(resu._data{indi}, 2); resu._name{2}(indi, 1) = df._name{2}(indc(indi)); resu._over{2}(1, indi) = df._over{2}(indc(indi)); resu._type{indi} = df._type{indc(indi)}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |