[Pkg-octave-commit] [octave-dataframe] 01/05: Imported Upstream version 1.0.1
Sébastien Villemot
sebastien at debian.org
Thu Sep 18 13:55:33 UTC 2014
This is an automated email from the git hooks/post-receive script.
sebastien pushed a commit to branch master
in repository octave-dataframe.
commit a1894564a327e5790705e36a564677e8564dbe78
Author: Sébastien Villemot <sebastien at debian.org>
Date: Thu Sep 18 15:44:40 2014 +0200
Imported Upstream version 1.0.1
---
DESCRIPTION | 4 +-
NEWS | 11 +++---
inst/@dataframe/private/df_matassign.m | 67 +++++++++++++++++++---------------
inst/@dataframe/private/df_pad.m | 23 +++++++++++-
4 files changed, 67 insertions(+), 38 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index a43c8f9..55b17f4 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Name: dataframe
-Version: 1.0.0
-Date: 2014-03-28
+Version: 1.0.1
+Date: 2014-09-09
Author: Pascal Dupuis
Maintainer: The Octave Community
Title: Data Frame
diff --git a/NEWS b/NEWS
index fd70ae0..6f9e35f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,8 @@
-Summary of important user-visible changes for dataframe 1.0.0:
+Summary of important user-visible changes for dataframe 1.0.1:
-------------------------------------------------------------------
- ** dataframe 1.0.0 is an official release. It is compatible with 3.6 and
- 3.8 branch. The 'conv' permits to apply some regexp on a line-by-line
- basis, in order to read text writtent with locales where decimal
- separator is not a dot.
+ ** dataframe 1.0.1 is an bug-fixing release. It is compatible with 3.6 and
+ 3.8 branch. When constructing a dataframe by passing a cell array, the
+ column names are infered from the first line and types from the second
+ line. In case of bogus column types, the type is changed to "char" and
+ the content taken literally.
diff --git a/inst/@dataframe/private/df_matassign.m b/inst/@dataframe/private/df_matassign.m
index 550160d..314bae8 100644
--- a/inst/@dataframe/private/df_matassign.m
+++ b/inst/@dataframe/private/df_matassign.m
@@ -183,7 +183,11 @@ function df = df_matassign(df, S, indc, ncol, RHS)
dummy = all (cellfun ('isnumeric', ...
RHS(~cellfun ('isempty', RHS(:, 1)), 1)));
else
- dummy = isnumeric(RHS{1, 1});
+ if (0 == size (RHS, 1))
+ dummy = false;
+ else
+ dummy = isnumeric (RHS{1, 1});
+ endif
endif
dummy = dummy && (~isempty (cname) && size (cname{1}, 2) < 1);
if (dummy)
@@ -249,7 +253,7 @@ function df = df_matassign(df, S, indc, ncol, RHS)
endif
endif
- if (iscell(RHS)) %# we must pad on a column-by-column basis
+ if (iscell (RHS)) %# we must pad on a column-by-column basis
%# verify that each cell contains a non-empty vector, and that sizes
%# are compatible
%# dummy = cellfun ('size', RHS(:), 2);
@@ -272,7 +276,7 @@ function df = df_matassign(df, S, indc, ncol, RHS)
if (size (cname, 1) > indc)
ncol = size (RHS, 2); indc = 1:ncol;
else
- keyboard
+ if (debug_on_error ()) keyboard; endif
endif
endif
@@ -313,9 +317,9 @@ function df = df_matassign(df, S, indc, ncol, RHS)
if (indc(indi) > df._cnt(2))
%# perform dynamic resizing one-by-one, to get type right
if (isempty (ctype) || length (ctype) < indc(indi))
- df = df_pad(df, 2, indc(indi)-df._cnt(2), class(RHS{1, indj}));
+ df = df_pad (df, 2, indc(indi)-df._cnt(2), class (RHS{1, indj}));
else
- df = df_pad(df, 2, indc(indi)-df._cnt(2), ctype{indj});
+ df = df_pad (df, 2, indc(indi)-df._cnt(2), ctype{indj});
endif
endif
if (nrow == df._cnt(1))
@@ -329,7 +333,7 @@ function df = df_matassign(df, S, indc, ncol, RHS)
case {'double' }
dummy = fillfunc (indj);
otherwise
- dummy = cast(fillfunc (indj), df._type{indc(indi)});
+ dummy = cast (fillfunc (indj), df._type{indc(indi)});
endswitch
else
%# keeps indexes in sync as cell elements may be empty
@@ -350,8 +354,9 @@ function df = df_matassign(df, S, indc, ncol, RHS)
catch
fprintf (2, "Something went wrong while converting colum %d\n", indj);
fprintf (2, "Error was: %s\n", lasterr ());
- dummy = unique(cellfun(@class, RHS(:, indj), ...
- 'UniformOutput', false));
+ keyboard;
+ dummy = unique (cellfun (@class, RHS(:, indj), ...
+ 'UniformOutput', false));
if (any (strmatch ("char", dummy, "exact")))
fprintf (2, "Downclassing to char\n");
%# replace the actual column, of type numeric, by a char
@@ -376,8 +381,10 @@ function df = df_matassign(df, S, indc, ncol, RHS)
dummy = ...
sprintf ("Assignement failed for colum %d, of type %s and length %d,\nwith new content\n%s", ...
indj, df._type{indc(indi)}, length (indr), disp (RHS(:, indj)));
+ keyboard
error (dummy);
endif
+ if (debug_on_error ()) keyboard; endif
end_try_catch
if (size (dummy, 1) < df._cnt(1))
dummy(end+1:df._cnt(1), :) = NA;
@@ -385,22 +392,25 @@ function df = df_matassign(df, S, indc, ncol, RHS)
else
%# partial assignement -- extract actual data and update
dummy = df._data{indc(indi)};
- try
- switch (df._type{indc(indi)})
- case {'char' } %# use a cell array to hold strings
- dummy(indr, 1) = cellfun(@num2str, RHS(:, indj), ...
- 'UniformOutput', false);
- case {'double' }
- dummy(indr, :) = fillfunc (indj);
- otherwise
- dummy(indr, :) = cast(fillfunc (indj), df._type{indc(indi)});
- endswitch
- catch
- dummy = ...
- sprintf ("Assignement failed for colum %d, of type %s and length %d,\nwith new content\n%s", ...
- indj, df._type{indc(indi)}, length (indr), disp (RHS(:, indj)));
- error (dummy);
- end_try_catch
+ if (size (RHS, 1) > 0)
+ %# pad content
+ try
+ switch (df._type{indc(indi)})
+ case {'char' } %# use a cell array to hold strings
+ dummy(indr, 1) = cellfun(@num2str, RHS(:, indj), ...
+ 'UniformOutput', false);
+ case {'double' }
+ dummy(indr, :) = fillfunc (indj);
+ otherwise
+ dummy(indr, :) = cast(fillfunc (indj), df._type{indc(indi)});
+ endswitch
+ catch
+ dummy = ...
+ sprintf ("Assignement failed for colum %d, of type %s and length %d,\nwith new content\n%s", ...
+ indj, df._type{indc(indi)}, length (indr), disp (RHS(:, indj)));
+ error (dummy);
+ end_try_catch
+ endif
endif
df._data{indc(indi)} = dummy; df._rep{indc(indi)} = 1:size (dummy, 2);
indj = indj + 1;
@@ -436,7 +446,7 @@ function df = df_matassign(df, S, indc, ncol, RHS)
df._data{indc(indi)} = feval (@subsasgn, df._data{indc(indi)}, S, ...
RHS._data{indi}(:, RHS._rep{indi}));
catch
- disp (lasterr ()); disp('line 516 ???'); keyboard
+ disp (lasterr ()); disp('line 445 ???'); keyboard
end_try_catch
else
df._data{indc(indi)} = feval (@subsasgn, df._data{indc(indi)}, S, ...
@@ -490,8 +500,7 @@ function df = df_matassign(df, S, indc, ncol, RHS)
df._data{indc(indi)} = fillfunc (df._data{indc(indi)}, S, indi);
S = Sorig;
catch
- disp (lasterr ())
- disp ('line 491 '); keyboard
+ disp (lasterr ()); disp ('line 499 '); keyboard
end_try_catch
# catch
# if ndims(df._data{indc(indi)}) > 2,
@@ -567,10 +576,10 @@ function df = df_matassign(df, S, indc, ncol, RHS)
if (length (dummy) == ncol)
df._name{2}(indc, 1) = dummy;
else
- disp ('line 528 '); keyboard
+ disp ('line 575 '); keyboard
endif
else
- disp ('line 531 '); keyboard
+ disp ('line 578 '); keyboard
endif
end_try_catch
df._over{2}(1, indc) = false;
diff --git a/inst/@dataframe/private/df_pad.m b/inst/@dataframe/private/df_pad.m
index 7b8f624..4478205 100644
--- a/inst/@dataframe/private/df_pad.m
+++ b/inst/@dataframe/private/df_pad.m
@@ -51,7 +51,7 @@ function df = df_pad(df, dim, n, coltype=[])
for indi = (1:min (size (df._data, 2), df._cnt(2)))
neff = n + df._cnt(1) - size (df._data{indi}, 1);
if (neff > 0)
- m = size (df._data{indi}, 2);
+ m = max(1, size (df._data{indi}, 2));
switch df._type{indi}
case {'char'}
dummy = {}; dummy(1:neff, 1:m) = NA;
@@ -66,6 +66,9 @@ function df = df_pad(df, dim, n, coltype=[])
df._type{indi});
endswitch
df._data{indi} = dummy;
+ if (isempty (df._rep{indi}))
+ df._rep{indi} = 1;
+ endif
endif
endfor
df._cnt(1) = df._cnt(1) + n;
@@ -110,7 +113,23 @@ function df = df_pad(df, dim, n, coltype=[])
case {'logical'} %# there is no NA in logical type
dummy = repmat (false, df._cnt(1), 1);
otherwise
- dummy = cast (repmat (NA, df._cnt(1), 1), coltype{indi});
+ try
+ dummy = cast (repmat (NA, df._cnt(1), 1), coltype{indi});
+ catch
+ %# There was an issue -- transfer coltype to data
+ if (indc+indi > df._cnt(2))
+ dummy = {coltype{indi}}; coltype{indi} = 'char';
+ if (df._cnt(1) < 1)
+ %# nothing defined yet -- pad with one line
+ df._type{indc+indi} = coltype{indi};
+ df = df_pad (df, 1, 1);
+ endif
+ else
+ dummy = sprintf ("Trying to change type of column %d, which was %s, to %s", ...
+ indc+indi, df._type{indi}, coltype{indi});
+ error (dummy);
+ endif
+ end_try_catch
endswitch
df._data{indc+indi} = dummy;
df._rep{indc+indi} = 1;
--
Alioth's /home/groups/pkg-octave/bin/git-commit-notice on /srv/git.debian.org/git/pkg-octave/octave-dataframe.git
More information about the Pkg-octave-commit
mailing list