X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Frank.q;h=63319d9b7b75ae4b88bd4bca922c44603081eaad;hb=13e7983c183d6448d09cd8ed9644351b676af4d3;hp=10ad7715c7556a0333c5698b157e20e87c8cee5c;hpb=164d1274fcb70c54897f2a03fc7c27152ed4821a;p=pspp diff --git a/src/language/stats/rank.q b/src/language/stats/rank.q index 10ad7715c7..63319d9b7b 100644 --- a/src/language/stats/rank.q +++ b/src/language/stats/rank.q @@ -148,8 +148,8 @@ struct rank_spec }; -/* Function to use for testing for missing values */ -static mv_is_missing_func *value_is_missing; +/* Categories of missing values to exclude. */ +static enum mv_class exclude_values; static struct rank_spec *rank_specs; static size_t n_rank_specs; @@ -275,7 +275,7 @@ rank_cmd (struct dataset *ds, const struct sort_criteria *sc, reader = casefile_get_destructive_reader (cf) ; criteria.crits[criteria.crit_cnt - 1] = sc->crits[i]; assert ( sc->crits[i].fv == var_get_case_index (src_vars[i]) ); - sorted_cf = sort_execute (reader, &criteria); + sorted_cf = sort_execute (reader, &criteria, NULL); casefile_destroy (cf); out = rank_sorted_casefile (sorted_cf, &criteria, @@ -547,7 +547,7 @@ rank_cases (struct casereader *cr, casereader_destroy (lookahead); cc_1 = cc; - if ( !value_is_missing (mv, this_value) ) + if ( !mv_is_value_missing (mv, this_value, exclude_values) ) cc += c; do @@ -556,7 +556,7 @@ rank_cases (struct casereader *cr, { const struct variable *dst_var = rs[i].destvars[dest_var_index]; - if ( value_is_missing (mv, this_value) ) + if ( mv_is_value_missing (mv, this_value, exclude_values) ) case_data_rw (&this_case, dst_var)->f = SYSMIS; else case_data_rw (&this_case, dst_var)->f = @@ -566,7 +566,7 @@ rank_cases (struct casereader *cr, } while (n-- > 0 && casereader_read_xfer (cr, &this_case)); - if ( !value_is_missing (mv, this_value) ) + if ( !mv_is_value_missing (mv, this_value, exclude_values) ) iter++; } @@ -615,7 +615,7 @@ rank_sorted_casefile (struct casefile *cf, double w = 0.0; this_value = case_data_idx( &group_case, ultimate_crit->fv); - if ( !value_is_missing(mv, this_value) ) + if ( !mv_is_value_missing (mv, this_value, exclude_values) ) w = dict_get_case_weight (dict, &group_case, &warn); while (casereader_read (lookahead, &this_case)) @@ -636,7 +636,7 @@ rank_sorted_casefile (struct casefile *cf, case_destroy (&group_case); case_move (&group_case, &this_case); } - if ( !value_is_missing (mv, this_value) ) + if ( !mv_is_value_missing (mv, this_value, exclude_values) ) w += c; case_destroy (&this_case); } @@ -773,11 +773,7 @@ cmd_rank (struct lexer *lexer, struct dataset *ds) } /* If /MISSING=INCLUDE is set, then user missing values are ignored */ - if (cmd.miss == RANK_INCLUDE ) - value_is_missing = mv_is_value_system_missing; - else - value_is_missing = mv_is_value_missing; - + exclude_values = cmd.miss == RANK_INCLUDE ? MV_SYSTEM : MV_ANY; /* Default to /RANK if no function subcommands are given */ if ( !( cmd.sbc_normal || cmd.sbc_ntiles || cmd.sbc_proportion || @@ -952,7 +948,7 @@ rank_custom_variables (struct lexer *lexer, struct dataset *ds, struct cmd_rank if (!parse_variables (lexer, dataset_dict (ds), &group_vars, &n_group_vars, - PV_NO_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH) ) + PV_NO_DUPLICATE | PV_NO_SCRATCH) ) { free (group_vars); return 0;