[gnumeric] Don't convert blank cells to 0 in LINEST. [#551234]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] Don't convert blank cells to 0 in LINEST. [#551234]
- Date: Sun, 4 Oct 2009 20:44:18 +0000 (UTC)
commit f8f1de551b230b16bafa8f7e14617652fa048cae
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Sun Oct 4 14:43:48 2009 -0600
Don't convert blank cells to 0 in LINEST. [#551234]
2009-10-04 Andreas J. Guelzow <aguelzow pyrshep ca>
* functions.c (gnumeric_linest): return an error in the presence of
blank cells [#551234]
NEWS | 7 ++++---
plugins/fn-stat/ChangeLog | 5 +++++
plugins/fn-stat/functions.c | 35 +++++++++++++++++++++++------------
3 files changed, 32 insertions(+), 15 deletions(-)
---
diff --git a/NEWS b/NEWS
index 5198af4..1c3e7b9 100644
--- a/NEWS
+++ b/NEWS
@@ -6,9 +6,10 @@ Albert Gräf:
Andreas:
* Add more ODF elements on ODF read. [#595750]
- * Fix 2-factor ANOVA with replication
- * Fix diagonal borders in ODF export/import
- * For freezing of panes consider edit cell A1 special [#594875]
+ * Fix 2-factor ANOVA with replication.
+ * Fix diagonal borders in ODF export/import.
+ * For freezing of panes consider edit cell A1 special. [#594875]
+ * Don't convert blank cells to 0 in LINEST. [#551234]
Jean:
* Make plugins GUI labels translatable. [#159806]
diff --git a/plugins/fn-stat/ChangeLog b/plugins/fn-stat/ChangeLog
index 1dad108..6db0ab3 100644
--- a/plugins/fn-stat/ChangeLog
+++ b/plugins/fn-stat/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-04 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * functions.c (gnumeric_linest): return an error in the presence of
+ blank cells [#551234]
+
2009-09-20 Morten Welinder <terra gnome org>
* Release 1.9.13
diff --git a/plugins/fn-stat/functions.c b/plugins/fn-stat/functions.c
index b74d114..e053804 100644
--- a/plugins/fn-stat/functions.c
+++ b/plugins/fn-stat/functions.c
@@ -3162,7 +3162,7 @@ gnumeric_linest (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
gnm_float **xss = NULL, *ys = NULL;
GnmValue *result = NULL;
- int nx, ny, dim, i;
+ int nx, ny, dim, i, ny_exp = 0;
int xarg = 1;
gnm_float *linres = NULL;
gboolean affine, stat, err;
@@ -3183,16 +3183,19 @@ gnumeric_linest (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (argv[0]->type == VALUE_ARRAY)
ytype = ARRAY;
- else if (argv[0]->v_range.cell.a.col == argv[0]->v_range.cell.b.col)
+ else if (argv[0]->v_range.cell.a.col == argv[0]->v_range.cell.b.col) {
+ ny_exp = argv[0]->v_range.cell.b.row - argv[0]->v_range.cell.a.row + 1;
ytype = SINGLE_COL;
- else if (argv[0]->v_range.cell.a.row == argv[0]->v_range.cell.b.row)
+ } else if (argv[0]->v_range.cell.a.row == argv[0]->v_range.cell.b.row) {
ytype = SINGLE_ROW;
- else ytype = OTHER;
+ ny_exp = argv[0]->v_range.cell.b.col - argv[0]->v_range.cell.a.col + 1;
+ } else ytype = OTHER;
if (argv[0]->type == VALUE_CELLRANGE)
ys = collect_floats_value (argv[0], ei->pos,
COLLECT_IGNORE_STRINGS |
- COLLECT_IGNORE_BOOLS,
+ COLLECT_IGNORE_BOOLS |
+ COLLECT_IGNORE_BLANKS,
&ny, &result);
else if (argv[0]->type == VALUE_ARRAY){
ny = 0;
@@ -3204,6 +3207,11 @@ gnumeric_linest (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (result || ny < 1)
goto out;
+ if (ny != ny_exp) {
+ result = value_new_error_NUM (ei->pos);
+ goto out;
+ }
+
/* TODO Better error-checking in next statement */
if (argv[1] == NULL || (ytype == ARRAY && argv[1]->type != VALUE_ARRAY) ||
@@ -3233,9 +3241,10 @@ gnumeric_linest (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
copy->v_range.cell.a.col = i;
copy->v_range.cell.b.col = i;
xss[i - firstcol] = collect_floats_value (copy, ei->pos,
- COLLECT_IGNORE_STRINGS |
- COLLECT_IGNORE_BOOLS,
- &nx, &result);
+ COLLECT_IGNORE_STRINGS |
+ COLLECT_IGNORE_BOOLS |
+ COLLECT_IGNORE_BLANKS,
+ &nx, &result);
if (result){
value_release (copy);
dim = i - firstcol; /* How many got allocated before failure*/
@@ -3265,9 +3274,10 @@ gnumeric_linest (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
copy->v_range.cell.a.row = i;
copy->v_range.cell.b.row = i;
xss[i - firstrow] = collect_floats_value (copy, ei->pos,
- COLLECT_IGNORE_STRINGS |
- COLLECT_IGNORE_BOOLS,
- &nx, &result);
+ COLLECT_IGNORE_STRINGS |
+ COLLECT_IGNORE_BOOLS |
+ COLLECT_IGNORE_BLANKS,
+ &nx, &result);
if (result){
value_release (copy);
dim = i - firstrow; /*How many got allocated before failure*/
@@ -3286,7 +3296,8 @@ gnumeric_linest (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
xss = g_new (gnm_float *, dim);
xss[0] = collect_floats_value (argv[1], ei->pos,
COLLECT_IGNORE_STRINGS |
- COLLECT_IGNORE_BOOLS,
+ COLLECT_IGNORE_BOOLS |
+ COLLECT_IGNORE_BLANKS,
&nx, &result);
if (result){
dim = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]