

def parse(schema, subsample_default):
    'Parses a generator schema as passed to CrosscatMetamodel.\n\n    schema is a tokenized expression of the form [[\'GUESS\', [\'*\']], [\'x\',\n    \'NUMERICAL\'], ...] that is passed to CrosscatMetamodel.create_generator and\n    represents the argument to "crosscat" in CREATE GENERATOR ... FOR ... USING\n    crosscat(...).\n\n    Returns a GeneratorSchema.\n\n    See test_crosscat_generator_schema.py for examples.\n    '
    guess = False
    subsample = subsample_default
    columns = []
    dep_constraints = []
    for directive in schema:
        if (directive == []):
            continue
        if ((not isinstance(directive, list)) or (len(directive) != 2) or (not isinstance(directive[0], basestring))):
            raise BQLError(None, ('Invalid crosscat column model directive: %r' % (directive,)))
        op = casefold(directive[0])
        if ((op == 'guess') and (directive[1] == ['*'])):
            guess = True
        elif ((op == 'subsample') and isinstance(directive[1], list) and (len(directive[1]) == 1)):
            subsample = _parse_subsample_clause(directive[1][0])
        elif (op == 'dependent'):
            constraint = (_parse_dependent_clause(directive[1]), True)
            dep_constraints.append(constraint)
        elif (op == 'independent'):
            constraint = (_parse_dependent_clause(directive[1]), False)
            dep_constraints.append(constraint)
        elif ((op != 'guess') and (casefold(directive[1]) != 'guess')):
            columns.append((directive[0], directive[1]))
        else:
            raise BQLError(None, ('Invalid crosscat column model: %r' % schema))
    return GeneratorSchema(guess=guess, subsample=subsample, columns=columns, dep_constraints=dep_constraints)

dataset/ETHPy150Open probcomp/bayeslite/src/metamodels/crosscat_generator_schema.py parse/VarMisuse@304/544 `directive`->`schema`