X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fexamine.c;h=cfe380d5b52c0181bf8f392b1da82c4973f30bae;hb=c84078d8498785e9a52945cc63fb663cd48027af;hp=295fca1a4a7b2d8a7d7cc9a8595767ad1ac6626d;hpb=e229a33394ba9708dd895760eabc47e9dc659c92;p=pspp diff --git a/src/language/stats/examine.c b/src/language/stats/examine.c index 295fca1a4a..cfe380d5b5 100644 --- a/src/language/stats/examine.c +++ b/src/language/stats/examine.c @@ -1,6 +1,6 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2012, 2013 Free Software Foundation, Inc. + Copyright (C) 2012, 2013, 2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -298,7 +298,7 @@ show_boxplot_grouped (const struct examine *cmd, int iact_idx) const struct ccase *c = categoricals_get_case_by_category_real (cmd->cats, iact_idx, grp); - const struct exploratory_stats *es = + struct exploratory_stats *es = categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, grp); ds_init_empty (&label); @@ -320,6 +320,7 @@ show_boxplot_grouped (const struct examine *cmd, int iact_idx) } boxplot_add_box (boxplot, es[v].box_whisker, ds_cstr (&label)); + es[v].box_whisker = NULL; ds_destroy (&label); } @@ -390,11 +391,12 @@ show_boxplot_variabled (const struct examine *cmd, int iact_idx) for (v = 0; v < cmd->n_dep_vars; ++v) { - const struct exploratory_stats *es = + struct exploratory_stats *es = categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, grp); boxplot_add_box (boxplot, es[v].box_whisker, var_to_string (cmd->dep_vars[v])); + es[v].box_whisker = NULL; } boxplot_submit (boxplot); @@ -1531,7 +1533,7 @@ update_n (const void *aux1, void *aux2 UNUSED, void *user_data, int v; const struct examine *examine = aux1; struct exploratory_stats *es = user_data; - + bool this_case_is_missing = false; /* LISTWISE missing must be dealt with here */ if (!examine->missing_pw) @@ -1630,13 +1632,15 @@ calculate_n (const void *aux1, void *aux2 UNUSED, void *user_data) value_init_pool (examine->pool, &es[v].maxima[i].identity, examine->id_width) ; value_init_pool (examine->pool, &es[v].minima[i].identity, examine->id_width) ; } - + + bool warn = true; for (reader = casereader_clone (es[v].sorted_reader); (c = casereader_read (reader)) != NULL; case_unref (c)) { const double val = case_data_idx (c, EX_VAL)->f; - const double wt = case_data_idx (c, EX_WT)->f; - + double wt = case_data_idx (c, EX_WT)->f; + wt = var_force_valid_weight (examine->wv, wt, &warn); + moments_pass_two (es[v].mom, val, wt); if (es[v].histogram) @@ -1796,6 +1800,12 @@ cleanup_exploratory_stats (struct examine *cmd) statistic_destroy (&es[v].histogram->parent); moments_destroy (es[v].mom); + if (es[v].box_whisker) + { + stat = &es[v].box_whisker->parent.parent; + stat->destroy (stat); + } + casereader_destroy (es[v].sorted_reader); } } @@ -1934,7 +1944,8 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) examine.boxplot = false; examine.spreadlevelplot = false; examine.sl_power = 0; - + examine.dep_vars = NULL; + examine.n_dep_vars = 0; examine.dict = dataset_dict (ds); /* Accept an optional, completely pointless "/VARIABLES=" */ @@ -1991,6 +2002,8 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) int extr = 5; if (lex_match (lexer, T_LPAREN)) { + if (!lex_force_int (lexer)) + goto error; extr = lex_integer (lexer); if (extr < 0)