From: <cde...@us...> - 2012-03-11 20:53:40
|
Revision: 9817 http://octave.svn.sourceforge.net/octave/?rev=9817&view=rev Author: cdemills Date: 2012-03-11 20:53:31 +0000 (Sun, 11 Mar 2012) Log Message: ----------- apply the emptiness test in dataframe.m only if more than one row Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/cat.m trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m trunk/octave-forge/extra/dataframe/inst/@dataframe/display.m trunk/octave-forge/extra/dataframe/inst/@dataframe/find.m trunk/octave-forge/extra/dataframe/inst/@dataframe/fold.m trunk/octave-forge/extra/dataframe/inst/@dataframe/horzcat.m trunk/octave-forge/extra/dataframe/inst/@dataframe/inv.m trunk/octave-forge/extra/dataframe/inst/@dataframe/isfield.m trunk/octave-forge/extra/dataframe/inst/@dataframe/isscalar.m trunk/octave-forge/extra/dataframe/inst/@dataframe/isvector.m trunk/octave-forge/extra/dataframe/inst/@dataframe/ne.m trunk/octave-forge/extra/dataframe/inst/@dataframe/permute.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_allmeta.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_basecomp.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_check_char_array.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_colmeta.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_func.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_mapper2.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_matassign.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_name2idx.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_pad.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_strjust.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_strset.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_thirddim.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_whole.m trunk/octave-forge/extra/dataframe/inst/@dataframe/prod.m trunk/octave-forge/extra/dataframe/inst/@dataframe/repmat.m trunk/octave-forge/extra/dataframe/inst/@dataframe/reshape.m trunk/octave-forge/extra/dataframe/inst/@dataframe/size.m trunk/octave-forge/extra/dataframe/inst/@dataframe/sort.m trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m trunk/octave-forge/extra/dataframe/inst/@dataframe/sum.m trunk/octave-forge/extra/dataframe/inst/@dataframe/summary.m trunk/octave-forge/extra/dataframe/inst/@dataframe/sumsq.m trunk/octave-forge/extra/dataframe/inst/@dataframe/vertcat.m Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/cat.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/cat.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/cat.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -29,172 +29,172 @@ %# $Id$ %# - if (!isa(A, 'dataframe')), - A = dataframe(A); + if (~isa (A, 'dataframe')), + A = dataframe (A); endif switch dim case 1 resu = A; - for indi = 1:length(varargin), - B = varargin{indi}; - if !isa(B, 'dataframe'), - if iscell(B) && 2 == length(B), - B = dataframe(B{2}, 'rownames', B{1}); - else - B = dataframe(B, 'colnames', inputname(2+indi)); - endif - endif - if resu._cnt(2) != B._cnt(2), - error('Different number of columns in dataframes'); - endif - %# do not duplicate empty names - if !isempty(resu._name{1}) || !isempty(B._name{1}), - if length(resu._name{1}) < resu._cnt(1), - resu._name{1}(end+1:resu._cnt(1), 1) = {''}; - endif - if length(B._name{1}) < B._cnt(1), - B._name{1}(end+1:B._cnt(1), 1) = {''}; - endif - resu._name{1} = vertcat(resu._name{1}(:), B._name{1}(:)); - resu._over{1} = [resu._over{1} B._over{1}]; - endif - resu._cnt(1) = resu._cnt(1) + B._cnt(1); - if size(resu._ridx, 2) < size(B._ridx, 2), - resu._ridx(:, end+1:size(B._ridx, 2)) = NA; - elseif size(resu._ridx, 2) > size(B._ridx, 2), - B._ridx(:, end+1:size(resu._ridx, 2)) = NA; - endif - resu._ridx = [resu._ridx; B._ridx]; - %# find data with same column names - dummy = A._over{2} & B._over{2}; - indA = true(1, resu._cnt(2)); - indB = true(1, resu._cnt(2)); - for indj = 1:resu._cnt(2), - if (dummy(indj)), - indk = strmatch(resu._name{2}(indj), B._name{2}, 'exact'); - if (~isempty(indk)), - indk = indk(1); - if ~strcmp(resu._type{indj}, B._type{indk}), - error("Trying to mix columns of different types"); - endif - endif - else - indk = indj; - endif - resu._data{indj} = [resu._data{indj}; B._data{indk}]; - indA(indj) = false; indB(indk) = false; - endfor - if any(indA) || any(indB) - error('Different number/names of columns in dataframe'); - endif - + for indi = (1:length (varargin)) + B = varargin{indi}; + if (~isa (B, 'dataframe')) + if (iscell (B) && 2 == length (B)) + B = dataframe (B{2}, 'rownames', B{1}); + else + B = dataframe (B, 'colnames', inputname(2+indi)); + endif + endif + if (resu._cnt(2) ~= B._cnt(2)) + error ('Different number of columns in dataframes'); + endif + %# do not duplicate empty names + if (~isempty (resu._name{1}) || ~isempty (B._name{1})) + if (length (resu._name{1}) < resu._cnt(1)) + resu._name{1}(end+1:resu._cnt(1), 1) = {''}; + endif + if (length (B._name{1}) < B._cnt(1)) + B._name{1}(end+1:B._cnt(1), 1) = {''}; + endif + resu._name{1} = vertcat (resu._name{1}(:), B._name{1}(:)); + resu._over{1} = [resu._over{1} B._over{1}]; + endif + resu._cnt(1) = resu._cnt(1) + B._cnt(1); + if (size (resu._ridx, 2) < size (B._ridx, 2)) + resu._ridx(:, end+1:size(B._ridx, 2)) = NA; + elseif (size (resu._ridx, 2) > size (B._ridx, 2)) + B._ridx(:, end+1:size(resu._ridx, 2)) = NA; + endif + resu._ridx = [resu._ridx; B._ridx]; + %# find data with same column names + dummy = A._over{2} & B._over{2}; + indA = true (1, resu._cnt(2)); + indB = true (1, resu._cnt(2)); + for indj = (1:resu._cnt(2)) + if (dummy(indj)) + indk = strmatch (resu._name{2}(indj), B._name{2}, 'exact'); + if (~isempty (indk)) + indk = indk(1); + if (~strcmp (resu._type{indj}, B._type{indk})) + error ("Trying to mix columns of different types"); + endif + endif + else + indk = indj; + endif + resu._data{indj} = [resu._data{indj}; B._data{indk}]; + indA(indj) = false; indB(indk) = false; + endfor + if (any (indA) || any (indB)) + error ('Different number/names of columns in dataframe'); + endif + endfor case 2 resu = A; - for indi = 1:length(varargin), - B = varargin{indi}; - if !isa(B, 'dataframe'), - if iscell(B) && 2 == length(B), - B = dataframe(B{2}, 'colnames', B{1}); - else - B = dataframe(B, 'colnames', inputname(2+indi)); - endif - B._ridx = resu._ridx; %# make them compatibles - endif - if resu._cnt(1) != B._cnt(1), - error('Different number of rows in dataframes'); - endif - if any(resu._ridx(:) - B._ridx(:)) - error('dataframes row indexes not matched'); - endif - resu._name{2} = vertcat(resu._name{2}, B._name{2}); - resu._over{2} = [resu._over{2} B._over{2}]; - resu._data(resu._cnt(2)+(1:B._cnt(2))) = B._data; - resu._type(resu._cnt(2)+(1:B._cnt(2))) = B._type; - resu._cnt(2) = resu._cnt(2) + B._cnt(2); + for indi = (1:length (varargin)) + B = varargin{indi}; + if (~isa (B, 'dataframe')) + if (iscell (B) && 2 == length (B)) + B = dataframe (B{2}, 'colnames', B{1}); + else + B = dataframe (B, 'colnames', inputname(2+indi)); + endif + B._ridx = resu._ridx; %# make them compatibles + endif + if (resu._cnt(1) ~= B._cnt(1)) + error ('Different number of rows in dataframes'); + endif + if (any(resu._ridx(:) - B._ridx(:))) + error ('dataframes row indexes not matched'); + endif + resu._name{2} = vertcat (resu._name{2}, B._name{2}); + resu._over{2} = [resu._over{2} B._over{2}]; + resu._data(resu._cnt(2)+(1:B._cnt(2))) = B._data; + resu._type(resu._cnt(2)+(1:B._cnt(2))) = B._type; + resu._cnt(2) = resu._cnt(2) + B._cnt(2); endfor case 3 resu = A; - for indi = 1:length(varargin), - B = varargin{indi}; - if (!isa(B, 'dataframe')), - if (iscell(B) && 2 == length(B)), - B = dataframe(B{2}, 'rownames', B{1}); - else - B = dataframe(B, 'colnames', inputname(indi+2)); - endif - endif - if (resu._cnt(1) != B._cnt(1)), - error('Different number of rows in dataframes'); - endif - if (resu._cnt(2) != B._cnt(2)), - error('Different number of columns in dataframes'); - endif - %# to be merged against 3rd dim, rownames must be equals, if - %# non-empty. Columns are merged based upon their name; columns - %# with identic content are kept. + for indi = (1:length (varargin)) + B = varargin{indi}; + if (~isa (B, 'dataframe')) + if (iscell (B) && 2 == length (B)), + B = dataframe (B{2}, 'rownames', B{1}); + else + B = dataframe (B, 'colnames', inputname(indi+2)); + endif + endif + if (resu._cnt(1) ~= B._cnt(1)) + error ('Different number of rows in dataframes'); + endif + if (resu._cnt(2) ~= B._cnt(2)), + error ('Different number of columns in dataframes'); + endif + %# to be merged against 3rd dim, rownames must be equals, if + %# non-empty. Columns are merged based upon their name; columns + %# with identic content are kept. - if size(resu._ridx, 2) < size(B._ridx, 2), - resu._ridx(:, end+1:size(B._ridx, 2)) = NA; - elseif size(resu._ridx, 2) > size(B._ridx, 2), - B._ridx(:, end+1:size(resu._ridx, 2)) = NA; - endif - resu._ridx = cat(3, resu._ridx, B._ridx); - %# find data with same column names - indA = true(1, resu._cnt(2)); - indB = true(1, resu._cnt(2)); - dummy = A._over{2} & B._over{2}; - for indj = 1:resu._cnt(2), - if (dummy(indj)), - indk = strmatch(resu._name{2}(indj), B._name{2}, 'exact'); - if (~isempty(indk)), - indk = indk(1); - if (~strcmp(resu._type{indj}, B._type{indk})), - error("Trying to mix columns of different types"); - endif - endif - else - indk = indj; - endif - if (all([isnumeric(resu._data{indj}) isnumeric(B._data{indk})])), - %# iterate over the columns of resu and B - op1 = resu._data{indj}; op2 = B._data{indk}; - for ind2=1:columns(op2), - indr = false; - for ind1=1:columns(op1), - if (all(abs(op1(:, ind1) - op2(:, ind2)) <= eps)), - resu._rep{indj} = [resu._rep{indj} ind1]; - indr = true; - break; - endif - endfor - if (!indr), - %# pad in the second dim - resu._data{indj} = [resu._data{indj}, B._data{indk}]; - resu._rep{indj} = [resu._rep{indj} 1+length(resu._rep{indj})]; - endif - endfor - else - resu._data{indj} = [resu._data{indj} B._data{indk}]; - resu._rep{indj} = [resu._rep{indj} 1+length(resu._rep({indj}))]; - endif - indA(indj) = false; indB(indk) = false; - endfor - if (any(indA) || any(indB)), - error('Different number/names of columns in dataframe'); - endif + if (size(resu._ridx, 2) < size(B._ridx, 2)) + resu._ridx(:, end+1:size(B._ridx, 2)) = NA; + elseif (size(resu._ridx, 2) > size(B._ridx, 2)) + B._ridx(:, end+1:size(resu._ridx, 2)) = NA; + endif + resu._ridx = cat (3, resu._ridx, B._ridx); + %# find data with same column names + indA = true (1, resu._cnt(2)); + indB = true (1, resu._cnt(2)); + dummy = A._over{2} & B._over{2}; + for indj = (1:resu._cnt(2)) + if (dummy(indj)) + indk = strmatch (resu._name{2}(indj), B._name{2}, 'exact'); + if (~isempty (indk)), + indk = indk(1); + if (~strcmp (resu._type{indj}, B._type{indk})), + error("Trying to mix columns of different types"); + endif + endif + else + indk = indj; + endif + if (all ([isnumeric(resu._data{indj}) isnumeric(B._data{indk})])), + %# iterate over the columns of resu and B + op1 = resu._data{indj}; op2 = B._data{indk}; + for ind2 = (1:columns (op2)) + indr = false; + for ind1 = (1:columns (op1)) + if (all (abs (op1(:, ind1) - op2(:, ind2)) <= eps)), + resu._rep{indj} = [resu._rep{indj} ind1]; + indr = true; + break; + endif + endfor + if (~indr), + %# pad in the second dim + resu._data{indj} = [resu._data{indj}, B._data{indk}]; + resu._rep{indj} = [resu._rep{indj} 1+length(resu._rep{indj})]; + endif + endfor + else + resu._data{indj} = [resu._data{indj} B._data{indk}]; + resu._rep{indj} = [resu._rep{indj} 1+length(resu._rep({indj}))]; + endif + indA(indj) = false; indB(indk) = false; + endfor + if (any (indA) || any (indB)) + error ('Different number/names of columns in dataframe'); + endif endfor - resu = df_thirddim(resu); + resu = df_thirddim (resu); otherwise - error('Incorrect call to cat'); + error ('Incorrect call to cat'); endswitch %# disp('End of cat'); keyboard Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -92,7 +92,7 @@ seeked = []; trigger =[]; unquot = true; sep = "\t,"; cmt_lines = []; locales = "C"; -if (length(varargin) > 0) +if (length (varargin) > 0) indi = 1; %# loop over possible arguments while (indi <= size (varargin, 2)) @@ -155,7 +155,7 @@ endwhile endif -if (!isempty (seeked) && !isempty (trigger)) +if (~isempty (seeked) && ~isempty (trigger)) error ('seeked and trigger are mutuallly incompatible arguments'); endif @@ -175,10 +175,10 @@ unwind_protect dummy = tilde_expand (x); fid = fopen (dummy); - if (fid != -1) + if (fid ~= -1) df._src{end+1, 1} = dummy; dummy = fgetl (fid); - if (!strcmp (dummy, UTF8_BOM)) + if (~strcmp (dummy, UTF8_BOM)) frewind (fid); endif %# slurp everything and convert doubles to char, avoiding @@ -188,10 +188,10 @@ in = []; endif unwind_protect_cleanup - if (fid != -1) fclose (fid); endif + if (fid ~= -1) fclose (fid); endif end_unwind_protect - if (!isempty (in)) + if (~isempty (in)) %# explicit list taken from 'man pcrepattern' -- we enclose all %# vertical separators in case the underlying regexp engine %# doesn't have them all. @@ -212,7 +212,7 @@ %# lines, 'UniformOutput', false); %# extract fields content = cellfun (@(x) strsplit (x, sep), lines, \ 'UniformOutput', false); %# extract fields - indl = 1; indj = 1; %# disp('line 151 '); keyboard + indl = 1; indj = 1; %#disp('line 151 '); keyboard if (~isempty (seeked)) while (indl <= length (lines)) dummy = content{indl}; @@ -246,7 +246,7 @@ endif x = cell (1+length (lines)-indl, size(dummy, 2)); empty_lines = []; cmt_lines = []; - while (indl <= length(lines)) + while (indl <= length (lines)) dummy = content{indl}; if (all (cellfun ('size', dummy, 2) == 0)) empty_lines = [empty_lines indj]; @@ -273,7 +273,7 @@ catch %# if the previous test fails, try a simpler one in = regexp (dummy{indk}, '[^'' ]+', 'match'); - if (!isempty(in)) + if (~isempty (in)) x(indj, indk) = in{1}; %# else %# x(indj, indk) = []; @@ -284,7 +284,7 @@ x(indj, indk) = regexp (dummy{indk}, '[^ ].*', 'match'); endif else - if (!isempty (regexp (dummy{indk}, '[/:]'))) + if (~isempty (regexp (dummy{indk}, '[/:]'))) %# try to convert to a date [timeval, nfields] = strptime( dummy{indk}, [char(37) 'd/' char(37) 'm/' char(37) 'Y ' char(37) 'T']); @@ -293,7 +293,7 @@ timeval); %# try to extract the usec field, if any idx = regexp (dummy{indk}, timestr, 'end'); - if (!isempty (idx)) + if (~isempty (idx)) idx = idx + 1; if (ispunct (dummy{indk}(idx))) idx = idx + 1; @@ -310,12 +310,12 @@ endfor indl = indl + 1; indj = indj + 1; endwhile - if (!isempty(empty_lines)) + if (~isempty (empty_lines)) x(empty_lines, :) = []; endif %# detect empty columns empty_lines = find (0 == sum (cellfun ('size', x, 2))); - if (!isempty(empty_lines)) + if (~isempty (empty_lines)) x(:, empty_lines) = []; endif clear UTF8_BOM fid in lines indl the_line content empty_lines @@ -326,7 +326,7 @@ %# fallback, avoiding a recursive call idx.type = '()'; - if (!isa (x, 'char')) + if (~isa (x, 'char')) indj = df._cnt(2)+(1:size (x, 2)); else %# at this point, reading some filename failed @@ -337,7 +337,7 @@ if (2 == length (x)) %# use the intermediate value as destination column [indc, ncol] = df_name2idx (df._name{2}, x{1}, df._cnt(2), "column"); - if (ncol != 1) + if (ncol ~= 1) error (["With two-elements cell, the first should resolve " ... "to a single column"]); endif @@ -362,7 +362,7 @@ %# allow overwriting of column names df._over{2}(1, indj) = true; else - if (!isempty(indj)) + if (~isempty (indj)) if (1 == length (df._name{2}) && length (df._name{2}) < \ length (indj)) [df._name{2}(indj, 1), df._over{2}(1, indj)] ... @@ -374,15 +374,15 @@ df._name{2} = genvarname (df._name{2}); endif endif - if (!isempty (indj)) + 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 %# df = subsasgn(df, idx, x); <= call directly lower level - df = df_matassign (df, idx, indj, length(indj), x); - if (!isempty (cmt_lines)) - df._cmt = vertcat(df._cmt, cellstr(cmt_lines)); + df = df_matassign (df, idx, indj, length (indj), x); + if (~isempty (cmt_lines)) + df._cmt = vertcat (df._cmt, cellstr (cmt_lines)); cmt_lines = []; endif else Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/display.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/display.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/display.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -29,7 +29,7 @@ %# generate header name dummy = inputname (1); - if (isempty(dummy)) + if (isempty (dummy)) dummy = "ans"; endif @@ -41,7 +41,7 @@ dummy, df._cnt); endif - if (!isempty (df._src)) + if (~isempty (df._src)) for indi = (1:size (df._src, 1)) head = strvcat\ (head, [repmat("Src: ", size (df._src{indi, 1}, 1), 1)\ @@ -49,7 +49,7 @@ endfor endif - if (!isempty (df._cmt)) + if (~isempty (df._cmt)) for indi = (1:size(df._cmt, 1)) head = strvcat\ (head, [repmat("Comment: ", size (df._cmt{indi, 1}, 1), 1)\ @@ -58,7 +58,7 @@ endif if (all (df._cnt > 0)) %# stop for empty df - dummy=[]; vspace = repmat (' ', df._cnt(1), 1); + dummy = []; vspace = repmat (' ', df._cnt(1), 1); indi = 1; %# the real, unfolded index %# loop over columns where the corresponding _data really exists for indc = (1:min (df._cnt(2), size (df._data, 2))) @@ -85,7 +85,7 @@ tmp_str = df._data{indc}(:, indk); %#get the whole column indj = cellfun ('isprint', tmp_str, 'UniformOutput', false); indj = ~cellfun ('all', indj); - for indr = (1:length(indj)) + for indr = (1:length (indj)) if (indj(indr)), if (isna (tmp_str{indr})), tmp_str{indr} = "NA"; @@ -125,10 +125,10 @@ vspace = [' '; ' '; vspace]; %# second line content resu = []; - if (!isempty (df._ridx)) + if (~isempty (df._ridx)) for (ind1 = 1:size (df._ridx, 2)) if ((1 == size(df._ridx, 3)) && \ - (any (!isna (df._ridx(1:df._cnt(1), ind1))))) + (any (~isna (df._ridx(1:df._cnt(1), ind1))))) dummy{2, 1} = [sprintf("_%d", ind1) ; "Nr"]; dummy{3, 1} = disp (df._ridx(1:df._cnt(1), ind1)); indi = regexp (dummy{3, 1}, '\b.*\b', 'match', 'dotexceptnewline'); @@ -140,7 +140,7 @@ endif else for ind2 = (1:size (df._ridx, 3)) - if (any (!isna (df._ridx(1:df._cnt(1), ind1, ind2)))), + if (any (~isna (df._ridx(1:df._cnt(1), ind1, ind2)))), dummy{2, 1} = [sprintf("_%d.%d", ind1, ind2) ; "Nr"]; dummy{3, 1} = disp (df._ridx(1:df._cnt(1), ind1, ind2)); indi = regexp (dummy{3, 1}, '\b.*\b', 'match', 'dotexceptnewline'); @@ -165,7 +165,7 @@ endif %# insert a vertical space - if (!isempty(dummy{3, 2})) + if (~isempty (dummy{3, 2})) indi = ~cellfun ('isempty', dummy{3, 2}); if (any (indi)) try Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/find.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/find.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/find.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -26,35 +26,35 @@ switch nargout case {0, 1} - resu = []; mz = max(cellfun(@length, df._rep)); - for indc = 1:df._cnt(2), - [indr, inds] = feval(@find, df._data{indc}(:, df._rep{indc})); - %# create a vector the same size as indr - dummy = indr; dummy(:) = indc; - resu = [resu; sub2ind([df._cnt(1:2) mz], indr, dummy, inds)]; + resu = []; mz = max (cellfun (@length, df._rep)); + for indc = (1:df._cnt(2)) + [indr, inds] = feval (@find, df._data{indc}(:, df._rep{indc})); + %# create a vector the same size as indr + dummy = indr; dummy(:) = indc; + resu = [resu; sub2ind([df._cnt(1:2) mz], indr, dummy, inds)]; endfor - varargout{1} = sort(resu); + varargout{1} = sort (resu); case 2 nz = 0; idx_i = []; idx_j = []; - for indc = 1:df._cnt(2), - [dum1, dum2] = feval(@find, df._data{indc}(:, df._rep{indc})); - idx_i = [idx_i; dum1]; - idx_j = [idx_j; nz + dum2]; - nz = nz + df._cnt(1)*length(df._rep{indc}); + for indc = (1:df._cnt(2)) + [dum1, dum2] = feval (@find, df._data{indc}(:, df._rep{indc})); + idx_i = [idx_i; dum1]; + idx_j = [idx_j; nz + dum2]; + nz = nz + df._cnt(1)*length (df._rep{indc}); endfor varargout{1} = idx_i; varargout{2} = idx_j; case 3 nz = 0; idx_i = []; idx_j = []; val = []; - for indc = 1:df._cnt(2), - [dum1, dum2, dum3] = feval(@find, df._data{indc}(:, df._rep{indc})); - idx_i = [idx_i; dum1]; - idx_j = [idx_j; nz + dum2]; - val = [val; dum3]; - nz = nz + df._cnt(1)*length(df._rep{indc}); + for indc = (1:df._cnt(2)) + [dum1, dum2, dum3] = feval (@find, df._data{indc}(:, df._rep{indc})); + idx_i = [idx_i; dum1]; + idx_j = [idx_j; nz + dum2]; + val = [val; dum3]; + nz = nz + df._cnt(1)*length (df._rep{indc}); endfor varargout{1} = idx_i; varargout{2} = idx_j; varargout{3} = val; otherwise - print_usage('find'); + print_usage ('find'); endswitch endfunction Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/fold.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/fold.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/fold.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -32,65 +32,63 @@ %# switch dim case 1 - [indr, nrow] = df_name2idx(df._name{1}, indr, df._cnt(1), 'row'); - [indc, ncol] = df_name2idx(df._name{2}, indc, df._cnt(2), 'column'); + [indr, nrow] = df_name2idx (df._name{1}, indr, df._cnt(1), 'row'); + [indc, ncol] = df_name2idx (df._name{2}, indc, df._cnt(2), 'column'); - if (indr(1) > 1), + if (indr(1) > 1) slice_size = indr(1) - 1; %# we can't use directly resu = df(1:slice_size, :, :) S.type = '()'; S.subs = { 1:slice_size, ':', ':', 'dataframe'}; - resu = subsref(df, S); + resu = subsref (df, S); %# how many columns for each slice - targets = cellfun(@length, df._rep); + targets = cellfun (@length, df._rep); %# a test function to determine if the location is free - for indj = 1:df._cnt(2), - if (any(indj == indc)), - continue; - endif - switch df._type{indj} - case { 'char' } - testfunc{indj} = @(x, indr, indc) ... - !isna(x{indr, indc}); - otherwise - testfunc{indj} = @(x, indr, indc) ... - !isna(x(indr, indc)); - endswitch + for indj = (1:df._cnt(2)) + if (any (indj == indc)) + continue; + endif + switch (df._type{indj}) + case { 'char' } + testfunc{indj} = @(x, indr, indc) ... + ~isna (x{indr, indc}); + otherwise + testfunc{indj} = @(x, indr, indc) ... + ~isna (x(indr, indc)); + endswitch endfor - for indi = indr, - %# where does this line go ? - where = find(df._data{indc}(1:slice_size, 1) ... - == df._data{indc}(indi, 1)); - if (!isempty(where)), - %# transfering one line -- loop over columns - for indj = 1:df._cnt(2), - if any(indj == indc), - continue; - endif - - if (testfunc{indj}(resu._data{indj}, where, targets(indj))), - %# add one more sheet - resu = df_pad(resu, 3, 1, indj); - targets(indj) = targets(indj) + 1; - endif - %# transfer field - stop - resu._data{indj}(where, targets(indj)) = ... - df._data{indj}(indi, 1); - endfor - %# update row index - resu._ridx(where, max(targets)) = df._ridx(indi); - else - disp('line 65: FIXME'); keyboard; - endif + for indi = (indr) + %# where does this line go ? + where = find (df._data{indc}(1:slice_size, 1) ... + == df._data{indc}(indi, 1)); + if (~isempty (where)) + %# transfering one line -- loop over columns + for indj = (1:df._cnt(2)) + if (any (indj == indc)) + continue; + endif + + if (testfunc{indj}(resu._data{indj}, where, targets(indj))) + %# add one more sheet + resu = df_pad(resu, 3, 1, indj); + targets(indj) = targets(indj) + 1; + endif + %# transfer field + stop + resu._data{indj}(where, targets(indj)) = ... + df._data{indj}(indi, 1); + endfor + %# update row index + resu._ridx(where, max(targets)) = df._ridx(indi); + else + disp ('line 65: FIXME'); keyboard; + endif endfor else - - disp('line 70: FIXME '); keyboard + disp ('line 70: FIXME '); keyboard endif - endswitch Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/horzcat.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/horzcat.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/horzcat.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -24,10 +24,10 @@ %# $Id$ %# - for indi = 1:length(varargin), - varargin{indi} = dataframe(varargin{indi}, 'colnames', inputname(1+indi));, + for indi = (1:length (varargin)) + varargin{indi} = dataframe (varargin{indi}, 'colnames', inputname(1+indi));, endfor - resu = cat(2, df, varargin{:}); + resu = cat (2, df, varargin{:}); endfunction Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/inv.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/inv.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/inv.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -29,24 +29,24 @@ %# $Id$ %# - if (length(df._cnt) > 2 || (df._cnt(1) != df._cnt(2))), - error("Dataframe is not square"); + if (length (df._cnt) > 2 || (df._cnt(1) ~= df._cnt(2))) + error ("Dataframe is not square"); endif %# quick and dirty conversion - [dummy, rcond] = inv(horzcat(df._data{:})); + [dummy, rcond] = inv (horzcat (df._data{:})); resu = df_allmeta(df); - [resu._name{2}, resu._name{1}] = deal(resu._name{1}, resu._name{2}); - [resu._over{2}, resu._over{1}] = deal(resu._over{1}, resu._over{2}); - if (isempty(resu._name{2})), - resu._name{2} = cellstr(repmat('_', resu._cnt(2), 1)); - resu._over{2} = ones(1, resu._cnt(2)); + [resu._name{2}, resu._name{1}] = deal (resu._name{1}, resu._name{2}); + [resu._over{2}, resu._over{1}] = deal (resu._over{1}, resu._over{2}); + if (isempty (resu._name{2})), + resu._name{2} = cellstr (repmat('_', resu._cnt(2), 1)); + resu._over{2} = ones (1, resu._cnt(2)); endif - for indi = resu._cnt(1):-1:1, + for indi = (resu._cnt(1):-1:1) resu._data{indi} = dummy(:, indi); endfor - resu._type(:) = class(dummy); + resu._type(:) = class (dummy); endfunction Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/isfield.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/isfield.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/isfield.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -35,57 +35,57 @@ %# $Id$ %# - if !isa(df, 'dataframe'), + if (~isa (df, 'dataframe')) resu = false; return; endif - if nargin <2 || nargin > 3, - print_usage(); + if (nargin < 2 || nargin > 3) + print_usage (); resu = false; return; endif - if 2 == nargin, strict = false; endif + if (2 == nargin) strict = false; endif - if isa(name, 'char'), - if strict, %# use strmatch to get indexes - for indi = size(name, 1):-1:1, - dummy = strmatch(name(indi, :), df._name{2}, "exact"); - resu(indi, 1) = !isempty(dummy); - for indj = 1:length(dummy), - idx(indi, indj) = dummy(indj); - endfor + if (isa (name, 'char')) + if (strict) %# use strmatch to get indexes + for indi = (size (name, 1):-1:1) + dummy = strmatch (name(indi, :), df._name{2}, "exact"); + resu(indi, 1) = ~isempty (dummy); + for indj = (1:length (dummy)) + idx(indi, indj) = dummy(indj); + endfor endfor else - for indi = size(name, 1):-1:1, - try - dummy = df_name2idx(df._name{2}, name(indi, :), \ - df._cnt(2), 'column'); - resu(indi, 1) = !isempty(dummy); - for indj = 1:length(dummy), - idx(indi, indj) = dummy(indj); - endfor - catch - resu(indi, 1) = false; idx(indi, 1) = 0; - end_try_catch + for indi = (size (name, 1):-1:1) + try + dummy = df_name2idx (df._name{2}, name(indi, :), \ + df._cnt(2), 'column'); + resu(indi, 1) = ~isempty (dummy); + for indj = (1:length (dummy)) + idx(indi, indj) = dummy(indj); + endfor + catch + resu(indi, 1) = false; idx(indi, 1) = 0; + end_try_catch endfor endif - elseif isa(name, 'cell'), - if strict, %# use strmatch to get indexes - for indi = size(name, 1):-1:1, - dummy = strmatch(name{indi}, df._name{2}, "exact"); - resu{indi, 1} = !isempty(dummy); - idx{indi, 1} = dummy; + elseif (isa (name, 'cell')) + if (strict) %# use strmatch to get indexes + for indi = (size (name, 1):-1:1) + dummy = strmatch (name{indi}, df._name{2}, "exact"); + resu{indi, 1} = ~isempty (dummy); + idx{indi, 1} = dummy; endfor else - for indi = length(name):-1:1, - try - dummy = df_name2idx(df._name{2}, name{indi}, \ - df._cnt(2), 'column'); - keyboard - resu{indi, 1} = !isempty(dummy); idx{indi, 1} = dummy; - catch - resu{indi, 1} = false; cnt{indi, 1} = 0; - end_try_catch + for indi = (length (name):-1:1) + try + dummy = df_name2idx (df._name{2}, name{indi}, \ + df._cnt(2), 'column'); + keyboard + resu{indi, 1} = ~isempty (dummy); idx{indi, 1} = dummy; + catch + resu{indi, 1} = false; cnt{indi, 1} = 0; + end_try_catch endfor endif endif Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/isscalar.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/isscalar.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/isscalar.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -26,6 +26,6 @@ %# $Id$ %# - resu = ismatrix(df) & (length(find(df._cnt > 1)) < 1); + resu = ismatrix (df) & (length (find (df._cnt > 1)) < 1); endfunction Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/isvector.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/isvector.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/isvector.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -26,6 +26,6 @@ %# $Id$ %# - resu = ismatrix(df) & (length(find(df._cnt > 1)) <= 1); + resu = ismatrix (df) & (length (find (df._cnt > 1)) <= 1); endfunction Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/ne.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/ne.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/ne.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -1,7 +1,7 @@ function resu = ne(A, B); %# function resu = ne(A, B) - %# Implements the '!=' operator when at least one argument is a dataframe. + %# Implements the '~=' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis <Pas...@uc...> %% @@ -27,6 +27,6 @@ %# $Id$ %# - resu = df_func(@ne, A, B); + resu = df_func (@ne, A, B); endfunction Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/permute.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/permute.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/permute.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -24,21 +24,21 @@ %# $Id$ %# - resu = dataframe([]); + resu = dataframe ([]); - if (length(df._cnt) >= length(perm)), + if (length (df._cnt) >= length (perm)) resu._cnt = df._cnt(perm); else resu._cnt = [df._cnt 1](perm); endif - if (ndims(df._ridx) < 3), - resu._ridx = permute(df._ridx, [min(perm(1), 2) min(perm(2:end))]); + if (ndims (df._ridx) < 3) + resu._ridx = permute (df._ridx, [min(perm(1), 2) min(perm(2:end))]); else - resu._ridx = permute(df._ridx, perm); + resu._ridx = permute (df._ridx, perm); endif - if (size(resu._ridx, 1) < resu._cnt(1)), + if (size (resu._ridx, 1) < resu._cnt(1)) %# adjust index size, if required resu._ridx(end+1:resu._cnt(1), :, :) = NA; endif @@ -46,13 +46,13 @@ if (2 == perm(1)), resu._name{1} = df._name{2}; resu._over{1} = df._over{2}; - indc = length(resu._name{1}); + indc = length (resu._name{1}); indi = resu._cnt(1) - indc; - if (indi > 0), + if (indi > 0) %# generate a name for the new row(s) - dummy = cstrcat(repmat('_', indi, 1), ... - strjust(num2str(indc + (1:indi).'), 'left')); - resu._name{1}(indc + (1:indi)) = cellstr(dummy); + dummy = cstrcat (repmat ('_', indi, 1), ... + strjust (num2str (indc + (1:indi).'), 'left')); + resu._name{1}(indc + (1:indi)) = cellstr (dummy); resu._over{1}(1, indc + (1:indi)) = true; endif else @@ -61,7 +61,7 @@ endif - if (2 == perm(2)), + if (2 == perm(2)) resu._name{2} = df._name{2}; resu._over{2} = df._over{2}; else @@ -69,41 +69,41 @@ resu._over{2} = df._over{1}; endif - if (isempty(resu._name{2})), + if (isempty (resu._name{2})), indc = 0; else - indc = length(resu._name{2}); + indc = length (resu._name{2}); endif indi = resu._cnt(2) - indc; - if (indi > 0), + if (indi > 0) %# generate a name for the new column(s) - dummy = cstrcat(repmat('_', indi, 1), ... - strjust(num2str(indc + (1:indi).'), 'left')); - resu._name{2}(indc + (1:indi)) = cellstr(dummy); + dummy = cstrcat (repmat ('_', indi, 1), ... + strjust (num2str (indc + (1:indi).'), 'left')); + resu._name{2}(indc + (1:indi)) = cellstr (dummy); resu._over{2}(1, indc + (1:indi)) = true; endif - if (2 != perm(2)), + if (2 ~= perm(2)), %# recompute the new type - dummy = zeros(0, class(sum(cellfun(@(x) zeros(1, class(x(1))),\ - df._data)))); - resu._type(1:resu._cnt(2)) = class(dummy); - dummy = permute(df_whole(df), perm); - for indi = 1:resu._cnt(2), - resu._data{indi} = squeeze(dummy(:, indi, :)); - resu._rep{indi} = 1:size(resu._data{indi}, 2); + dummy = zeros (0, class (sum (cellfun (@(x) zeros (1, class(x(1))),\ + df._data)))); + resu._type(1:resu._cnt(2)) = class (dummy); + dummy = permute (df_whole(df), perm); + for indi = (1:resu._cnt(2)) + resu._data{indi} = squeeze (dummy(:, indi, :)); + resu._rep{indi} = 1:size (resu._data{indi}, 2); endfor else %# 2 == perm(2) - if (1 == perm(1)), %# blank operation + if (1 == perm(1)) %# blank operation resu._type = df._type; resu._data = df._data; resu._rep = df._rep; else - for indi = 1:resu._cnt(2), - unfolded = df._data{indi}(:, df._rep{indi}); - resu._data{indi} = permute(unfolded, [2 1]); - resu._rep{indi} = 1:size(resu._data{indi}, 2); - resu._type{indi} = df._type{indi}; + for indi = (1:resu._cnt(2)) + unfolded = df._data{indi}(:, df._rep{indi}); + resu._data{indi} = permute (unfolded, [2 1]); + resu._rep{indi} = 1:size (resu._data{indi}, 2); + resu._type{indi} = df._type{indi}; endfor endif endif Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_allmeta.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_allmeta.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_allmeta.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -28,33 +28,33 @@ %# $Id$ %# - resu = dataframe([]); + resu = dataframe ([]); - if (isempty(dim)), + if (isempty (dim)), dim = df._cnt(1:2); else dim = dim(1:2); %# ignore third dim, if any endif - resu._cnt(1:2) = min(dim, df._cnt(1:2)); - if (!isempty(df._name{1})), + resu._cnt(1:2) = min (dim, df._cnt(1:2)); + if (~isempty(df._name{1})) resu._name{1} = df._name{1}(1:resu._cnt(1)); resu._over{1} = df._over{1}(1:resu._cnt(1)); endif - if (!isempty(df._name{2})), + if (~isempty(df._name{2})) resu._name{2} = df._name{2}(1:resu._cnt(2)); resu._over{2} = df._over{2}(1:resu._cnt(2)); endif - if (!isempty(df._ridx)), - if (size(df._ridx, 2) >= resu._cnt(2)), + if (~isempty(df._ridx)) + if (size (df._ridx, 2) >= resu._cnt(2)), resu._ridx = df._ridx(1:resu._cnt(1), :, :); else resu._ridx = df._ridx(1:resu._cnt(1), 1, :); endif endif %# init it with the right orientation - resu._data = cell(size(df._data)); - resu._rep = cell(size(df._rep)); + resu._data = cell (size (df._data)); + resu._rep = cell (size (df._rep)); resu._type = df._type(1:resu._cnt(2)); resu._src = df._src; resu._cmt = df._cmt; Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_basecomp.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_basecomp.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_basecomp.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -30,162 +30,162 @@ %# $Id$ %# - if 1 == length(itercol), + if (1 == length (itercol)) strict = false; else strict = itercol(2); itercol = itercol(1); endif - if (iscell(A)), A = dataframe(A); endif - if (iscell(B)), B = dataframe(B); endif + if (iscell (A)), A = dataframe (A); endif + if (iscell (B)), B = dataframe (B); endif - switch (func2str(func)), + switch (func2str (func)), case 'bsxfun' %# bsxfun compatibility rule: if there is at least one singleton %# dim, the smallest is repeated to reach the size of the %# greatest. Otherwise, all dims must be equal. - if (any(size(A)(1:2) != size(B)(1:2))) - if (!any (1 == [size(A) size(B)])) - error('bsxfun: both arguments must have the same dim, of one of them must have at least one singleton dim'); - else - Csize = max([size(A)(1:2); size(B)(1:2)]); - endif + if (any (size (A)(1:2) ~= size (B)(1:2))) + if (~any (1 == [size(A) size(B)])) + error ('bsxfun: both arguments must have the same dim, of one of them must have at least one singleton dim'); + else + Csize = max ([size(A)(1:2); size(B)(1:2)]); + endif else - Csize = size(A)(1:2); + Csize = size (A)(1:2); endif case 'mldivide' - if (isscalar(A)), - Csize = size(B)(1:2); + if (isscalar (A)), + Csize = size (B)(1:2); else - if (size(A, 1) != size(B, 1)), - error("Non compatible row sizes (op1 is %dx%d, op2 is %dx%d)",\ - size(A), size(B)(1:2)); - endif - Csize = [size(A, 2) size(B, 2)]; + if (size (A, 1) ~= size (B, 1)) + error ("Non compatible row sizes (op1 is %dx%d, op2 is %dx%d)",\ + size (A), size (B)(1:2)); + endif + Csize = [size(A, 2) size(B, 2)]; endif otherwise %# if strict is set, B may not be non-scalar vs scalar - if ((!(isscalar(A) || isscalar(B)))||(strict && isscalar(A))), - if (itercol), %# requires full compatibility - Csize = size(A)(1:2); - if (any(Csize - size(B)(1:2))), - %# disp([size(A) size(B)]) - error("Non compatible row and columns sizes (op1 is %dx%d, op2 is %dx%d)",\ - Csize, size(B)); - endif - else %# compatibility with matrix product - if (size(A, 2) - size(B, 1)), - error("Non compatible columns vs. rows size (op1 is %dx%d, op2 is %dx%d)",\ - size(A)(1:2), size(B)(1:2)); - endif - Csize = [size(A, 1) size(B, 2)]; - endif + if ((~(isscalar (A) || isscalar (B)))||(strict && isscalar (A))) + if (itercol), %# requires full compatibility + Csize = size (A)(1:2); + if (any (Csize - size (B)(1:2))) + %# disp([size(A) size(B)]) + error ("Non compatible row and columns sizes (op1 is %dx%d, op2 is %dx%d)",\ + Csize, size (B)); + endif + else %# compatibility with matrix product + if (size (A, 2) - size (B, 1)), + error ("Non compatible columns vs. rows size (op1 is %dx%d, op2 is %dx%d)",\ + size (A)(1:2), size (B)(1:2)); + endif + Csize = [size(A, 1) size(B, 2)]; + endif endif endswitch - if !(isscalar(A) || isscalar(B)) + if (~(isscalar (A) || isscalar (B))) C = []; - if (isa(A, 'dataframe')) - if (nargout > 2 && all(Csize == size(A)(1:2))), - C = df_allmeta(A, Csize); + if (isa (A, 'dataframe')) + if (nargout > 2 && all (Csize == size (A)(1:2))), + C = df_allmeta (A, Csize); endif - if (isa(B, 'dataframe')) - if (nargout > 2 && isempty(C) && all(Csize == size(B)(1:2))), - C = df_allmeta(B, Csize); - endif - if (strict), - %# compare indexes if both exist - if (!isempty(A._ridx)) - if (!isempty(B._ridx) && itercol), - if (any(A._ridx-B._ridx)), - error("Non compatible indexes"); - endif - endif - else - if (nargout > 2 && itercol), C._ridx = B._ridx; endif - endif - - if (itercol), - idxB = 1; %# row-row comparison - else - idxB = 2; %# row-col comparsion - endif - - if (!isempty(A._name{1})) - if (!isempty(B._name{idxB})) - dummy = !(strcmp(cellstr(A._name{1}), cellstr(B._name{idxB}))\ - | (A._over{1}(:)) | (B._over{idxB}(:))); - if (any(dummy)), - if (itercol), - error("Incompatible row names"); - else - error("Incompatible row vs. column names"); - endif - endif - dummy = A._over{1} > B._over{idxB}; - if (any(dummy)), - C._name{1}(dummy) = B._name{idxB}(dummy); - C._over{1}(dummy) = B._over{idxB}(dummy); - endif - endif - else - if (nargout > 2), - C._name{1} = B._name{idxB}; C._over{1} = B._over{idxB}; - endif - endif - - idxB = 3-idxB; - - if (!isempty(A._name{2})) - if (!isempty(B._name{idxB})) - dummy = !(strcmp(cellstr(A._name{2}), cellstr(B._name{2}))\ - | (A._over{2}(:)) | (B._over{2}(:))); - if (any(dummy)), - if (itercol), - error("Incompatible column vs row names"); - else - error("Incompatible column names"); - endif - endif - dummy = A._over{2} > B._over{idxB}; - if (any(dummy)), - C._name{2}(dummy) = B._name{idxB}(dummy); - C._over{2}(dummy) = B._over{idxB}(dummy); - endif - endif - else - if (nargout > 2 && !isempty(B._name{idxB})), - C._name{2} = B._name{idxB}; C._over{2} = B._over{idxB}; - endif - endif - endif + if (isa (B, 'dataframe')) + if (nargout > 2 && isempty (C) && all (Csize == size (B)(1:2))), + C = df_allmeta (B, Csize); + endif + if (strict) + %# compare indexes if both exist + if (~isempty (A._ridx)) + if (~isempty(B._ridx) && itercol) + if (any (A._ridx-B._ridx)), + error ("Non compatible indexes"); + endif + endif + else + if (nargout > 2 && itercol), C._ridx = B._ridx; endif + endif + + if (itercol), + idxB = 1; %# row-row comparison + else + idxB = 2; %# row-col comparsion + endif + + if (~isempty (A._name{1})) + if (~isempty (B._name{idxB})) + dummy = ~(strcmp (cellstr (A._name{1}), cellstr (B._name{idxB}))\ + | (A._over{1}(:)) | (B._over{idxB}(:))); + if (any (dummy)) + if (itercol), + error ("Incompatible row names"); + else + error ("Incompatible row vs. column names"); + endif + endif + dummy = A._over{1} > B._over{idxB}; + if (any (dummy)), + C._name{1}(dummy) = B._name{idxB}(dummy); + C._over{1}(dummy) = B._over{idxB}(dummy); + endif + endif + else + if (nargout > 2), + C._name{1} = B._name{idxB}; C._over{1} = B._over{idxB}; + endif + endif + + idxB = 3-idxB; + + if (~isempty(A._name{2})) + if (~isempty(B._name{idxB})) + dummy = ~(strcmp (cellstr (A._name{2}), cellstr (B._name{2}))\ + | (A._over{2}(:)) | (B._over{2}(:))); + if (any (dummy)), + if (itercol), + error ("Incompatible column vs row names"); + else + error ("Incompatible column names"); + endif + endif + dummy = A._over{2} > B._over{idxB}; + if (any (dummy)), + C._name{2}(dummy) = B._name{idxB}(dummy); + C._over{2}(dummy) = B._over{idxB}(dummy); + endif + endif + else + if (nargout > 2 && ~isempty (B._name{idxB})), + C._name{2} = B._name{idxB}; C._over{2} = B._over{idxB}; + endif + endif + endif - if (isempty(A._src) && nargout > 2 && !isempty(B._src)), - C._src = B._src; - endif - if (isempty(A._cmt) && nargout > 2 && !isempty(B._cmt)), - C._cmt = B._cmt; - endif + if (isempty (A._src) && nargout > 2 && ~isempty (B._src)), + C._src = B._src; + endif + if (isempty (A._cmt) && nargout > 2 && ~isempty (B._cmt)), + C._cmt = B._cmt; + endif else %# B is not a df - if (nargout > 2 && isempty(C)), - C = df_allmeta(A); - endif + if (nargout > 2 && isempty (C)), + C = df_allmeta (A); + endif endif else %# A is not a df if (nargout > 2), - if (all(Csize==size(B)(1:2))), - C = df_allmeta(B, Csize); - else - C = df_allmeta(B); - endif + if (all (Csize == size (B)(1:2))), + C = df_allmeta (B, Csize); + else + C = df_allmeta (B); + endif endif endif else %# both arg are scalar - if (nargout > 2), - if (isa(A, 'dataframe')) - C = df_allmeta(A); + if (nargout > 2) + if (isa (A, 'dataframe')) + C = df_allmeta (A); else - C = df_allmeta(B); + C = df_allmeta (B); endif endif endif Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_check_char_array.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_check_char_array.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_check_char_array.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -26,27 +26,27 @@ %# $Id$ %# - if 2 == nargin, required = [nelem 1]; endif + if (2 == nargin) required = [nelem 1]; endif - if nelem < required(1), - error("Too many elements to assign"); + if (nelem < required(1)) + error ("Too many elements to assign"); endif %# a zero-length element is still considered as a space by char - if isempty(x), x = ' '; endif + if (isempty (x)) x = ' '; endif - if size(x, 1) < max(required(1), nelem) + if (size (x, 1) < max (required(1), nelem)) %# pad vertically - dummy = repmat(' ', nelem-size(x, 1), 1); - resu = char(x, dummy); + dummy = repmat (' ', nelem-size (x, 1), 1); + resu = char (x, dummy); else resu = x; endif - if size(resu, 2) < required(2), + if (size (resu, 2) < required(2)) %# pad horizontally - dummy = repmat(' ', nelem, required(2)-size(resu, 2)); - resu = horzcat(resu, dummy); + dummy = repmat (' ', nelem, required(2)-size (resu, 2)); + resu = horzcat (resu, dummy); endif endfunction Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_colmeta.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_colmeta.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_colmeta.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -28,15 +28,15 @@ %# $Id: df_func.m 7943 2010-11-24 15:33:54Z cdemills $ %# - resu = dataframe([]); + resu = dataframe ([]); resu._cnt(2) = df._cnt(2); resu._name{2} = df._name{2}; resu._over{2} = df._over{2}; resu._type = df._type; %# init it with the right orientation - resu._data = cell(size(df._data)); - resu._rep = cell(size(df._rep)); + resu._data = cell (size (df._data)); + resu._rep = cell (size (df._rep)); resu._src = df._src; resu._cmt = df._cmt; Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -29,50 +29,50 @@ %# $Id$ %# - if length(col) > 1, - error("df_cow must work on a column-by-column basis"); + if (length (col) > 1) + error ("df_cow must work on a column-by-column basis"); endif - if (1 == length(S.subs)), + if (1 == length (S.subs)), inds = 1; else inds = S.subs{2}; endif - if (!isnumeric(inds)), - if !strcmp(inds, ':'), - error("Unknown sheet selector %s", inds); + if (~isnumeric(inds)) + if (~strcmp (inds, ':')) + error ("Unknown sheet selector %s", inds); endif - inds = 1:length(df._rep(col)); + inds = 1:length (df._rep(col)); endif - for indi = inds(:).', + for indi = (inds(:).') dummy = df._rep{col}; dummy(indi) = 0; - [t1, t2] = ismember(df._rep{col}(indi)(:), dummy); - for indj = t2(find(t2)), %# Copy-On-Write + [t1, t2] = ismember (df._rep{col}(indi)(:), dummy); + for indj = (t2(find (t2))) %# Copy-On-Write %# determines the index for the next column - t1 = 1+max(df._rep{col}); + t1 = 1 + max (df._rep{col}); %# duplicate the touched column - df._data{col} = horzcat(df._data{col}, \ - df._data{col}(:, df._rep{col}(indj))); - if (indi > 1), + df._data{col} = horzcat (df._data{col}, \ + df._data{col}(:, df._rep{col}(indj))); + if (indi > 1) %# a new column has been created df._rep{col}(indi) = t1; else %# update repetition index aliasing this one - df._rep{col}(find(dummy == indi)) = t1; + df._rep{col}(find (dummy == indi)) = t1; endif endfor endfor %# reorder S - if (length(S.subs) > 1), - if (S.subs{2} != 1 || length(S.subs{2}) > 1), + if (length (S.subs) > 1) + 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 - df = df_thirddim(df); + df = df_thirddim (df); endfunction Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_func.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_func.m 2012-03-11 20:34:47 UTC (rev 9816) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_func.m 2012-03-11 20:53:31 UTC (rev 9817) @@ -32,191 +32,191 @@ %# $Id$ %# - [A, B, resu] = df_basecomp(A, B, itercol, func); + [A, B, resu] = df_basecomp (A, B, itercol, func); itercol = itercol(1); %# drop second value - if (isa(B, 'dataframe')) - if (!isa(A, 'dataframe')), - if (isscalar(A)), - for indi = resu._cnt(2):-1:1, + if (isa (B, 'dataframe')) + if (~isa (A, 'dataframe')), + if (isscalar (A)), + for indi = (resu._cnt(2):-1:1) switch resu._type{indi} case "char" - resu._data{indi} = feval(func, A, char(B._data{indi})); + resu._data{indi} = feval (func, A, char (B._data{indi})); otherwise - resu._data{indi} = feval(func, A, B._data{indi}); + resu._data{indi} = feval (func, A, B._data{indi}); endswitch endfor resu._rep = B._rep; else - if (whole(1) && !whole(2)), - for indi = resu._cnt(2):-1:1, + if (whole(1) && ~whole(2)) + for indi = (resu._cnt(2):-1:1) switch resu._type{indi} case "char" - resu._data{indi} = feval(func, A, \ - char(B._data{indi}(:, B._rep{indi}))); + resu._data{indi} = feval (func, A, \ + char (B._data{indi}(:, B._rep{indi}))); otherwise - resu._data{indi} = feval(func, A, \ - B._data{indi}(:, B._rep{indi})); + resu._data{indi} = feval (func, A, \ + B._data{indi}(:, B._rep{indi})); endswitch - resu._rep{indi} = 1:size(resu._data{indi}, 2); + resu._rep{indi} = 1:size (resu._data{indi}, 2); endfor - elseif (itercol && !whole(2)), - for indi = resu._cnt(2):-1:1, + elseif (itercol && ~whole(2)), + for indi = (resu._cnt(2):-1:1) switch resu._type{indi} case "char" - resu._data{indi} = feval(func, squeeze(A(:, indi, :)), \ - char(B._data{indi}(:, B._rep{indi}))); + resu._data{indi} = feval (func, squeeze (A(:, indi, :)), \ + char (B._data{indi}(:, B._rep{indi}))); otherwise - resu._data{indi} = feval(func, squeeze(A(:, indi, :)), \ - B._data{indi}(:, B._rep{indi})); + resu._data{indi} = feval (func, squeeze (A(:, indi, :)), \ + B._data{indi}(:, B._rep{indi})); endswitch - resu._rep{indi} = 1:size(resu._data{indi}, 2); + resu._rep{indi} = 1:size (resu._data{indi}, 2); endfor - elseif (!whole(2)), - warning("no 3D yet"); - for indi = resu._cnt(2):-1:1, + elseif (~whole(2)), + warning ("no 3D yet"); + for indi = (resu._cnt(2):-1:1) switch resu._type{indi} case "char" - resu._data{indi} = feval(func, A(indi, :), char(B._data{indi})); + resu._data{indi} = feval (func, A(indi, :), char (B._data{indi})); otherwise - resu._data{indi} = feval(func, A(indi, :), B._data{indi}); + resu._data{indi} = feval (func, A(indi, :), B._data{indi}); endswitch endfor else - dummy = feval(func, A, df_whole(B)); - for indi = resu._cnt(2):-1:1, %# store column-wise - resu._data{indi} = sq... [truncated message content] |