X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Flevene.c;h=098fcc5a1ba9feba488060e3406f54f84364c998;hb=2a45a48f87553563cbf0f0b6dcc20396b3e5a27a;hp=fe04d294e1acfbf214dadea6a53717ccc9a37646;hpb=71eea20b080f51f1aa00ef35acf4f49ce742d10a;p=pspp diff --git a/src/math/levene.c b/src/math/levene.c index fe04d294e1..098fcc5a1b 100644 --- a/src/math/levene.c +++ b/src/math/levene.c @@ -22,6 +22,7 @@ #include "libpspp/misc.h" #include "libpspp/hmap.h" #include "data/value.h" +#include "data/val-type.h" #include #include @@ -44,7 +45,7 @@ struct levene /* Width of the categorical variable */ int gvw ; - /* The value deviding the the groups. Valid only for dichotomous categorical variable.*/ + /* The value dividing the groups. Valid only for dichotomous categorical variable.*/ const union value *cutpoint; @@ -223,12 +224,16 @@ levene_calculate (struct levene *nl) double numerator = 0.0; double nn = 0.0; - if ( nl->pass == 3 ) - { - nl->pass = 4; - } - assert (nl->pass == 4); + /* The Levene calculation requires three passes. + Normally this should have been done prior to calling this function. + However, in abnormal circumstances (eg. the dataset is empty) there + will have been no passes. + */ + assert (nl->pass == 0 || nl->pass == 3); + + if ( nl->pass == 0 ) + return SYSMIS; nl->denominator *= hmap_count (&nl->hmap) - 1;