def get_n_sets(petal_labels, dataset_labels):
    """Infer number of sets, check consistency"""
    n_sets = len(dataset_labels)
    for logic in petal_labels.keys():
        if len(logic) != n_sets:
            raise ValueError('Inconsistent petal and dataset labels')
        if not set(logic) <= {'0', '1'}:
            raise KeyError('Key not understood: ' + logic)
    return n_sets
