X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Ft-test.q;h=e8da73a96d1c5bdb1662bb0eda6b81bf7a94570f;hb=205eaea8e2d95e20baa2c00a495b0ac4f9646372;hp=3baa983a11614813f47b42055f1c63c1f7f0ee01;hpb=f903a8263cb82efeaa72eaab68252bd740778ffa;p=pspp-builds.git diff --git a/src/t-test.q b/src/t-test.q index 3baa983a..e8da73a9 100644 --- a/src/t-test.q +++ b/src/t-test.q @@ -27,6 +27,7 @@ #include #include "alloc.h" #include "str.h" +#include "case.h" #include "command.h" #include "lexer.h" #include "error.h" @@ -208,7 +209,7 @@ static int mode; static struct cmd_t_test cmd; - +static int bad_weight_warn; int cmd_t_test(void) @@ -296,6 +297,8 @@ cmd_t_test(void) else value_is_missing = is_missing; + bad_weight_warn = 1; + multipass_procedure_with_splits (calculate, &cmd); n_pairs=0; @@ -512,6 +515,7 @@ tts_custom_pairs (struct cmd_t_test *cmd UNUSED) n_pairs+=n_pairs_local; + free (vars); return 1; } @@ -530,7 +534,7 @@ parse_value (union value * v, int type ) { if (!lex_force_string ()) return 0; - strncpy (v->s, ds_value (&tokstr), ds_length (&tokstr)); + strncpy (v->s, ds_c_str (&tokstr), ds_length (&tokstr)); } lex_get (); @@ -627,7 +631,7 @@ ssbox_one_sample_init(struct ssbox *this, ssbox_base_init(this, hsize,vsize); tab_title (this->t, 0, _("One-Sample Statistics")); - tab_vline(this->t, TAL_2, 1,0,vsize); + tab_vline(this->t, TAL_2, 1,0,vsize - 1); tab_text (this->t, 1, 0, TAB_CENTER | TAT_TITLE, _("N")); tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("Mean")); tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation")); @@ -649,7 +653,7 @@ ssbox_independent_samples_init(struct ssbox *this, ssbox_base_init(this, hsize,vsize); tab_title (this->t, 0, _("Group Statistics")); - tab_vline(this->t,0,1,0,vsize); + tab_vline(this->t,0,1,0,vsize - 1); tab_text (this->t, 1, 0, TAB_CENTER | TAT_TITLE, indep_var->name); tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("N")); tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("Mean")); @@ -901,8 +905,8 @@ trbox_independent_samples_init(struct trbox *self, tab_text(self->t,10,2, TAB_CENTER | TAT_TITLE,_("Upper")); tab_joint_text(self->t, 9, 1, 10, 1, TAB_CENTER | TAT_PRINTF, - _("%d%% Confidence Interval of the Difference"), - (int)round(cmd->criteria*100.0)); + _("%g%% Confidence Interval of the Difference"), + cmd->criteria*100.0); } @@ -1045,7 +1049,7 @@ trbox_paired_init(struct trbox *self, trbox_base_init(self,n_pairs,hsize); tab_title (self->t, 0, _("Paired Samples Test")); tab_hline(self->t,TAL_1,2,6,1); - tab_vline(self->t,TAL_2,2,0,vsize); + tab_vline(self->t,TAL_2,2,0,vsize - 1); tab_joint_text(self->t,2,0,6,0,TAB_CENTER,_("Paired Differences")); tab_box(self->t,-1,-1,-1,TAL_1, 2,1,6,vsize-1); tab_box(self->t,-1,-1,-1,TAL_1, 6,0,hsize-1,vsize-1); @@ -1053,8 +1057,8 @@ trbox_paired_init(struct trbox *self, tab_vline(self->t,TAL_0,6,0,1); tab_joint_text(self->t, 5, 1, 6, 1, TAB_CENTER | TAT_PRINTF, - _("%d%% Confidence Interval of the Difference"), - (int)round(cmd->criteria*100.0)); + _("%g%% Confidence Interval of the Difference"), + cmd->criteria*100.0); tab_text (self->t, 2, 2, TAB_CENTER | TAT_TITLE, _("Mean")); tab_text (self->t, 3, 2, TAB_CENTER | TAT_TITLE, _("Std. Deviation")); @@ -1139,7 +1143,7 @@ trbox_one_sample_init(struct trbox *self, struct cmd_t_test *cmd ) trbox_base_init(self, cmd->n_variables,hsize); tab_title (self->t, 0, _("One-Sample Test")); tab_hline(self->t, TAL_1, 1, hsize - 1, 1); - tab_vline(self->t, TAL_2, 1, 0, vsize); + tab_vline(self->t, TAL_2, 1, 0, vsize - 1); tab_joint_text(self->t, 1, 0, hsize-1,0, TAB_CENTER | TAT_PRINTF, _("Test Value = %f"),cmd->n_testval); @@ -1148,8 +1152,8 @@ trbox_one_sample_init(struct trbox *self, struct cmd_t_test *cmd ) tab_joint_text(self->t,5,1,6,1,TAB_CENTER | TAT_PRINTF, - _("%d%% Confidence Interval of the Difference"), - (int)round(cmd->criteria*100.0)); + _("%g%% Confidence Interval of the Difference"), + cmd->criteria*100.0); tab_vline(self->t,TAL_0,6,1,1); tab_hline(self->t,TAL_1,5,6,2); @@ -1303,7 +1307,7 @@ common_calc (const struct ccase *c, void *_cmd) int i; struct cmd_t_test *cmd = (struct cmd_t_test *)_cmd; - double weight = dict_get_case_weight(default_dict,c); + double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn); /* Skip the entire case if /MISSING=LISTWISE is set */ @@ -1312,7 +1316,7 @@ common_calc (const struct ccase *c, void *_cmd) for(i=0; i< cmd->n_variables ; ++i) { struct variable *v = cmd->v_variables[i]; - const union value *val = &c->data[v->fv]; + const union value *val = case_data (c, v->fv); if (value_is_missing(val,v) ) { @@ -1324,7 +1328,7 @@ common_calc (const struct ccase *c, void *_cmd) /* Listwise has to be implicit if the independent variable is missing ?? */ if ( cmd->sbc_groups ) { - const union value *gv = &c->data[indep_var->fv]; + const union value *gv = case_data (c, indep_var->fv); if ( value_is_missing(gv,indep_var) ) { return 0; @@ -1336,7 +1340,7 @@ common_calc (const struct ccase *c, void *_cmd) { struct group_statistics *gs; struct variable *v = cmd->v_variables[i]; - const union value *val = &c->data[v->fv]; + const union value *val = case_data (c, v->fv); gs= &cmd->v_variables[i]->p.t_t.ugs; @@ -1403,7 +1407,7 @@ one_sample_calc (const struct ccase *c, void *cmd_) struct cmd_t_test *cmd = (struct cmd_t_test *)cmd_; - double weight = dict_get_case_weight(default_dict,c); + double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn); /* Skip the entire case if /MISSING=LISTWISE is set */ if ( cmd->miss == TTS_LISTWISE ) @@ -1411,7 +1415,7 @@ one_sample_calc (const struct ccase *c, void *cmd_) for(i=0; i< cmd->n_variables ; ++i) { struct variable *v = cmd->v_variables[i]; - const union value *val = &c->data[v->fv]; + const union value *val = case_data (c, v->fv); if (value_is_missing(val,v) ) { @@ -1424,7 +1428,7 @@ one_sample_calc (const struct ccase *c, void *cmd_) { struct group_statistics *gs; struct variable *v = cmd->v_variables[i]; - const union value *val = &c->data[v->fv]; + const union value *val = case_data (c, v->fv); gs= &cmd->v_variables[i]->p.t_t.ugs; @@ -1512,7 +1516,7 @@ paired_calc (const struct ccase *c, void *cmd_) struct cmd_t_test *cmd = (struct cmd_t_test *) cmd_; - double weight = dict_get_case_weight(default_dict,c); + double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn); /* Skip the entire case if /MISSING=LISTWISE is set , AND one member of a pair is missing */ @@ -1523,8 +1527,8 @@ paired_calc (const struct ccase *c, void *cmd_) struct variable *v0 = pairs[i].v[0]; struct variable *v1 = pairs[i].v[1]; - const union value *val0 = &c->data[v0->fv]; - const union value *val1 = &c->data[v1->fv]; + const union value *val0 = case_data (c, v0->fv); + const union value *val1 = case_data (c, v1->fv); if ( value_is_missing(val0,v0) || value_is_missing(val1,v1) ) @@ -1539,8 +1543,8 @@ paired_calc (const struct ccase *c, void *cmd_) struct variable *v0 = pairs[i].v[0]; struct variable *v1 = pairs[i].v[1]; - const union value *val0 = &c->data[v0->fv]; - const union value *val1 = &c->data[v1->fv]; + const union value *val0 = case_data (c, v0->fv); + const union value *val1 = case_data (c, v1->fv); if ( ( !value_is_missing(val0,v0) && !value_is_missing(val1,v1) ) ) { @@ -1674,9 +1678,9 @@ group_calc (const struct ccase *c, struct cmd_t_test *cmd) int i; int g; - const union value *gv = &c->data[indep_var->fv]; + const union value *gv = case_data (c, indep_var->fv); - const double weight = dict_get_case_weight(default_dict,c); + const double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn); if ( value_is_missing(gv,indep_var) ) { @@ -1688,7 +1692,7 @@ group_calc (const struct ccase *c, struct cmd_t_test *cmd) for(i=0; i< cmd->n_variables ; ++i) { struct variable *v = cmd->v_variables[i]; - const union value *val = &c->data[v->fv]; + const union value *val = case_data (c, v->fv); if (value_is_missing(val,v) ) { @@ -1698,7 +1702,7 @@ group_calc (const struct ccase *c, struct cmd_t_test *cmd) } - gv = &c->data[indep_var->fv]; + gv = case_data (c, indep_var->fv); g = get_group(gv,indep_var); @@ -1714,7 +1718,7 @@ group_calc (const struct ccase *c, struct cmd_t_test *cmd) struct group_statistics *gs = &var->p.t_t.gs[g]; - const union value *val=&c->data[var->fv]; + const union value *val = case_data (c, var->fv); if ( !value_is_missing(val,var) ) { @@ -1766,15 +1770,16 @@ calculate(const struct casefile *cf, void *cmd_) struct trbox test_results_box; struct casereader *r; - const struct ccase *c; + struct ccase c; struct cmd_t_test *cmd = (struct cmd_t_test *) cmd_; common_precalc(cmd); for(r = casefile_get_reader (cf); - casereader_read (r, &c) ; ) + casereader_read (r, &c) ; + case_destroy (&c)) { - common_calc(c,cmd); + common_calc(&c,cmd); } casereader_destroy (r); common_postcalc(cmd); @@ -1784,9 +1789,10 @@ calculate(const struct casefile *cf, void *cmd_) case T_1_SAMPLE: one_sample_precalc(cmd); for(r = casefile_get_reader (cf); - casereader_read (r, &c) ; ) + casereader_read (r, &c) ; + case_destroy (&c)) { - one_sample_calc(c,cmd); + one_sample_calc(&c,cmd); } casereader_destroy (r); one_sample_postcalc(cmd); @@ -1795,9 +1801,10 @@ calculate(const struct casefile *cf, void *cmd_) case T_PAIRED: paired_precalc(cmd); for(r = casefile_get_reader (cf); - casereader_read (r, &c) ; ) + casereader_read (r, &c) ; + case_destroy (&c)) { - paired_calc(c,cmd); + paired_calc(&c,cmd); } casereader_destroy (r); paired_postcalc(cmd); @@ -1807,9 +1814,10 @@ calculate(const struct casefile *cf, void *cmd_) group_precalc(cmd); for(r = casefile_get_reader (cf); - casereader_read (r, &c) ; ) + casereader_read (r, &c) ; + case_destroy (&c)) { - group_calc(c,cmd); + group_calc(&c,cmd); } casereader_destroy (r); group_postcalc(cmd);