X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fexamine.c;h=19c42fcad5aff5bb63d3b61fcd89458f76c7d218;hb=710f5de78998ae74020b8a401836dabca4df355e;hp=ad8a9baa767d525fdf645c1a8ec07d3dba312885;hpb=cd221d80fafb54e550398c6de105d4c1b7f02ba0;p=pspp diff --git a/src/language/stats/examine.c b/src/language/stats/examine.c index ad8a9baa76..19c42fcad5 100644 --- a/src/language/stats/examine.c +++ b/src/language/stats/examine.c @@ -71,7 +71,7 @@ static void append_value_name (const struct variable *var, const union value *val, struct string *str) { var_append_value_name (var, val, str); - if (var_is_value_missing (var, val, MV_ANY)) + if (var_is_value_missing (var, val)) ds_put_cstr (str, _(" (missing)")); } @@ -551,7 +551,7 @@ new_value_with_missing_footnote (const struct variable *var, struct pivot_footnote *missing_footnote) { struct pivot_value *pv = pivot_value_new_var_value (var, value); - if (var_is_value_missing (var, value, MV_USER)) + if (var_is_value_missing (var, value) == MV_USER) pivot_value_add_footnote (pv, missing_footnote); return pv; } @@ -1033,7 +1033,7 @@ create_n (const void *aux1, void *aux2 UNUSED) es[v].minimum = DBL_MAX; } - subcase_destroy (&ordering); + subcase_uninit (&ordering); return es; } @@ -1053,7 +1053,8 @@ update_n (const void *aux1, void *aux2 UNUSED, void *user_data, { const struct variable *var = examine->dep_vars[v]; - if (var_is_value_missing (var, case_data (c, var), examine->dep_excl)) + if (var_is_value_missing (var, case_data (c, var)) + & examine->dep_excl) { es[v].missing += weight; this_case_is_missing = true; @@ -1068,9 +1069,9 @@ update_n (const void *aux1, void *aux2 UNUSED, void *user_data, { struct ccase *outcase ; const struct variable *var = examine->dep_vars[v]; - const double x = case_data (c, var)->f; + const double x = case_num (c, var); - if (var_is_value_missing (var, case_data (c, var), examine->dep_excl)) + if (var_is_value_missing (var, case_data (c, var)) & examine->dep_excl) { es[v].missing += weight; continue; @@ -1090,11 +1091,11 @@ update_n (const void *aux1, void *aux2 UNUSED, void *user_data, /* Save the value and the ID to the writer */ assert (examine->id_idx != -1); - case_data_rw_idx (outcase, EX_VAL)->f = x; + *case_num_rw_idx (outcase, EX_VAL) = x; value_copy (case_data_rw_idx (outcase, EX_ID), case_data_idx (c, examine->id_idx), examine->id_width); - case_data_rw_idx (outcase, EX_WT)->f = weight; + *case_num_rw_idx (outcase, EX_WT) = weight; es[v].cc += weight; @@ -1134,7 +1135,7 @@ calculate_n (const void *aux1, void *aux2 UNUSED, void *user_data) es[v].sorted_reader = casewriter_make_reader (es[v].sorted_writer); es[v].sorted_writer = NULL; - imax = casereader_get_case_cnt (es[v].sorted_reader); + imax = casereader_get_n_cases (es[v].sorted_reader); es[v].maxima = pool_calloc (examine->pool, examine->calc_extremes, sizeof (*es[v].maxima)); es[v].minima = pool_calloc (examine->pool, examine->calc_extremes, sizeof (*es[v].minima)); @@ -1148,8 +1149,8 @@ calculate_n (const void *aux1, void *aux2 UNUSED, void *user_data) 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; - double wt = case_data_idx (c, EX_WT)->f; + const double val = case_num_idx (c, EX_VAL); + double wt = case_num_idx (c, EX_WT); wt = var_force_valid_weight (examine->wv, wt, &warn); moments_pass_two (es[v].mom, val, wt); @@ -1197,13 +1198,12 @@ calculate_n (const void *aux1, void *aux2 UNUSED, void *user_data) { const int n_os = 5 + examine->n_percentiles; - struct order_stats **os ; es[v].percentiles = pool_calloc (examine->pool, examine->n_percentiles, sizeof (*es[v].percentiles)); es[v].trimmed_mean = trimmed_mean_create (es[v].cc, 0.05); es[v].shapiro_wilk = NULL; - os = xcalloc (n_os, sizeof *os); + struct order_stats **os = XCALLOC (n_os, struct order_stats *); os[0] = &es[v].trimmed_mean->parent; es[v].quartiles[0] = percentile_create (0.25, es[v].cc); @@ -1372,7 +1372,7 @@ run_examine (struct examine *cmd, struct casereader *input) { struct ccase *c = casereader_peek (input, 0); - cmd->id_idx = case_get_value_cnt (c); + cmd->id_idx = case_get_n_values (c); input = casereader_create_arithmetic_sequence (input, 1.0, 1.0); case_unref (c); @@ -1568,15 +1568,10 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) { while (lex_is_number (lexer)) { + if (!lex_force_num_range_open (lexer, "PERCENTILES", 0, 100)) + goto error; double p = lex_number (lexer); - if (p <= 0 || p >= 100.0) - { - lex_error (lexer, - _("Percentiles must lie in the range (0, 100)")); - goto error; - } - examine.n_percentiles++; examine.ptiles = xrealloc (examine.ptiles, @@ -1661,7 +1656,7 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) } else if (lex_match_id (lexer, "REPORT")) { - examine.fctr_excl = MV_NEVER; + examine.fctr_excl = 0; } else if (lex_match_id (lexer, "NOREPORT")) { @@ -1806,8 +1801,7 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) if (percentiles_seen && examine.n_percentiles == 0) { examine.n_percentiles = 7; - examine.ptiles = xcalloc (examine.n_percentiles, - sizeof (*examine.ptiles)); + examine.ptiles = xcalloc (examine.n_percentiles, sizeof (*examine.ptiles)); examine.ptiles[0] = 5; examine.ptiles[1] = 10;