From 0c40cc9355d2ce0d88d3937b1bfe0cb9927510a3 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 19 May 2010 16:31:08 +0200 Subject: [PATCH] Fixed bug parsing binomial test. The NPAR TEST /BINOMIAL subcommand was supposed to take a default P value. But it didn't work. This change fixes that problem. --- src/language/stats/npar.q | 11 ++++++++++- tests/command/npar-binomial.sh | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/language/stats/npar.q b/src/language/stats/npar.q index 8c6f98f8..53579722 100644 --- a/src/language/stats/npar.q +++ b/src/language/stats/npar.q @@ -16,6 +16,7 @@ #include + #include #include @@ -133,6 +134,7 @@ npar_execute(struct casereader *input, casereader_destroy (input); } + int cmd_npar_tests (struct lexer *lexer, struct dataset *ds) { @@ -338,7 +340,9 @@ npar_custom_binomial (struct lexer *lexer, struct dataset *ds, btp->category1 = btp->category2 = btp->cutpoint = SYSMIS; - if ( lex_match(lexer, '(') ) + btp->p = 0.5; + + if ( lex_match (lexer, '(') ) { if ( lex_force_num (lexer) ) { @@ -349,6 +353,10 @@ npar_custom_binomial (struct lexer *lexer, struct dataset *ds, else return 0; } + else + /* Kludge: q2c swallows the '=' so put it back here */ + lex_put_back (lexer, '='); + if ( lex_match (lexer, '=') ) { @@ -377,6 +385,7 @@ npar_custom_binomial (struct lexer *lexer, struct dataset *ds, } else return 2; + } specs->n_tests++; diff --git a/tests/command/npar-binomial.sh b/tests/command/npar-binomial.sh index ea892b15..c2b8b1d7 100755 --- a/tests/command/npar-binomial.sh +++ b/tests/command/npar-binomial.sh @@ -178,7 +178,7 @@ END DATA. WEIGHT BY w. NPAR TESTS - /BINOMIAL(0.5) = x + /BINOMIAL = x . -- 2.30.2