""", (generator_id, population_id))}
raw_categories = \
sorted(bdb.sql_execute("""
SELECT colno, code, value FROM bayesdb_cgpm_category
WHERE generator_id = ?
""", (generator_id,)))
assert len(raw_categories) > 0
// compare core.bayesdb_variable_name
cat_variables = {colno: name for (colno, name) in
bdb.sql_execute("""
SELECT colno, name FROM bayesdb_variable
WHERE (generator_id IS NULL OR generator_id = ?)
AND population_id = ?
""", (generator_id, population_id))}
assert len(cat_variables) > 0
// Doing the join in python because i can"t figure out how to
// do it in sqlite SQL
import operator, itertools
groups = \
{colno: group for (colno, group) in
itertools.groupby(raw_categories, key=operator.itemgetter(0))}
assert len(groups) > 0
assert cat_variables[groups.keys()[0]]