Esempio n. 1
0
def model_apis():
    '''
    List api of each model.
    '''
    for spec in list_models():
        Model = import_model(spec).Model
        attrs = sorted(attr for attr in dir(Model) if not attr.startswith('_'))
        types = []
        methods = []
        constants = []
        for attr in attrs:
            var = getattr(Model, attr)
            if isinstance(var, type):
                types.append(attr)
            elif hasattr(var, '__call__'):
                methods.append(attr)
            else:
                constants.append(attr)
        print 'distributions.{}.models.{}.{}:'.format(
            spec['flavor'],
            spec['name'],
            Model.__name__)
        print '  types:\n    {}'.format('\n    '.join(types))
        print '  methods:\n    {}'.format('\n    '.join(methods))
        print '  constants:\n    {}'.format('\n    '.join(constants))
Esempio n. 2
0
def models_by_flavor():
    '''
    List models implemented of each flavor.
    '''
    flavors = defaultdict(lambda: [])
    for spec in list_models():
        flavors[spec['flavor']].append(spec['name'])
    for flavor in sorted(flavors):
        print 'flavor {}: {}'.format(flavor, ' '.join(sorted(flavors[flavor])))
Esempio n. 3
0
def flavors_by_model():
    '''
    List flavors implemented of each model.
    '''
    models = defaultdict(lambda: [])
    for spec in list_models():
        models[spec['name']].append(spec['flavor'])
    for model in sorted(models):
        print 'model {}: {}'.format(model, ' '.join(sorted(models[model])))
Esempio n. 4
0
def models_by_flavor():
    '''
    List models implemented of each flavor.
    '''
    flavors = defaultdict(lambda: [])
    for spec in list_models():
        flavors[spec['flavor']].append(spec['name'])
    for flavor in sorted(flavors):
        print 'flavor {}: {}'.format(flavor, ' '.join(sorted(flavors[flavor])))
Esempio n. 5
0
def flavors_by_model():
    '''
    List flavors implemented of each model.
    '''
    models = defaultdict(lambda: [])
    for spec in list_models():
        models[spec['name']].append(spec['flavor'])
    for model in sorted(models):
        print 'model {}: {}'.format(model, ' '.join(sorted(models[model])))
Esempio n. 6
0
def model_apis():
    '''
    List api of each model.
    '''
    for spec in list_models():
        Model = import_model(spec).Model
        attrs = sorted(attr for attr in dir(Model) if not attr.startswith('_'))
        types = []
        methods = []
        constants = []
        for attr in attrs:
            var = getattr(Model, attr)
            if isinstance(var, type):
                types.append(attr)
            elif hasattr(var, '__call__'):
                methods.append(attr)
            else:
                constants.append(attr)
        print 'distributions.{}.models.{}.{}:'.format(spec['flavor'],
                                                      spec['name'],
                                                      Model.__name__)
        print '  types:\n    {}'.format('\n    '.join(types))
        print '  methods:\n    {}'.format('\n    '.join(methods))
        print '  constants:\n    {}'.format('\n    '.join(constants))
Esempio n. 7
0
    seed_all,
)

try:
    import distributions.io.schema_pb2
    has_protobuf = True
except ImportError:
    has_protobuf = False

DATA_COUNT = 20
SAMPLE_COUNT = 1000
MIN_GOODNESS_OF_FIT = 1e-3

MODULES = {
    '{flavor}.models.{name}'.format(**spec): import_model(spec)
    for spec in list_models()
}

IS_FAST = {'dbg': False, 'hp': True, 'lp': True}


def model_is_fast(model):
    flavor = model.__name__.split('.')[1]
    return IS_FAST[flavor]


def iter_examples(module):
    assert_hasattr(module, 'EXAMPLES')
    EXAMPLES = module.EXAMPLES
    assert_is_instance(EXAMPLES, list)
    assert_true(EXAMPLES, 'no examples provided')
    seed_all,
)

try:
    import distributions.io.schema_pb2
    has_protobuf = True
except ImportError:
    has_protobuf = False

DATA_COUNT = 20
SAMPLE_COUNT = 1000
MIN_GOODNESS_OF_FIT = 1e-3

MODULES = {
    '{flavor}.models.{name}'.format(**spec): import_model(spec)
    for spec in list_models()
}

IS_FAST = {'dbg': False, 'hp': True, 'lp': True}


def model_is_fast(model):
    flavor = model.__name__.split('.')[1]
    return IS_FAST[flavor]


def iter_examples(module):
    assert_hasattr(module, 'EXAMPLES')
    EXAMPLES = module.EXAMPLES
    assert_is_instance(EXAMPLES, list)
    assert_true(EXAMPLES, 'no examples provided')