Don't crash if all categorical variables are empty
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 31 Oct 2009 06:04:25 +0000 (07:04 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 31 Oct 2009 06:04:25 +0000 (07:04 +0100)
src/math/categoricals.c

index d0762831a9b22e8c2766fbbd0010105be5601136..b1f0ce84d9a397bdca0c71062dab79988d9eef0f 100644 (file)
@@ -104,9 +104,7 @@ categoricals_dump (const struct categoricals *cat)
       struct hmap_node *node ;
       int x;
      
-      printf ("\n%s (%d)  CC=%g:\n", var_get_name (vp->var), vp->base_subscript, vp->cc);
-
-      assert (vp->reverse_value_map);
+      printf ("\n%s (%d)  CC=%g n_cats=%d:\n", var_get_name (vp->var), vp->base_subscript, vp->cc, vp->n_cats);
 
       printf ("Reverse map\n");
       for (x = 0 ; x < vp->n_cats; ++x)
@@ -215,7 +213,7 @@ categoricals_update (struct categoricals *cat, const struct ccase *c)
          node->cc = 0.0;
 
          hmap_insert (&cat->vp[i].map, &node->node,  hash);
-         cat->n_cats_total ++;
+         cat->n_cats_total++;
          node->subscript = cat->vp[i].n_cats++ ;
        }