Ejemplo n.º 1
0
def test_make_schema_noarg2_fail():
    schemaRule = [[lambda x: x[0:4] == 'Cat', {
        'type': 'categorical'
    }], [lambda x: x[0:4] == 'Int', {
        'type': 'count'
    }]]
    make_schema(schemaRule)
Ejemplo n.º 2
0
def test_make_schema_headers():
    refSchema = {
        'CatA': {
            'type': 'categorical'
        },
        'CatB': {
            'type': 'categorical'
        },
        'IntA': {
            'type': 'count'
        },
        'IntB': {
            'type': 'count'
        }
    }
    headers = ['IntA', 'IntB', 'CatA', 'CatB', 'Foo']
    schemaRule1 = [['Int.*', {
        'type': 'count'
    }], ['Cat.*', {
        'type': 'categorical'
    }]]
    schemaRule2 = [[lambda h, v: h[0:3] == 'Cat', {
        'type': 'categorical'
    }], [lambda h, v: h[0:3] == 'Int', {
        'type': 'count'
    }]]
    schema = make_schema(schemaRule1, headers=headers)
    assert schema == refSchema
    schema = make_schema(schemaRule2, headers=headers)
    assert schema == refSchema
Ejemplo n.º 3
0
def test_make_schema_noarg1_fail():
    schemaRule = [['Int.*', {
        'type': 'count'
    }], ['Cat.*', {
        'type': 'categorical'
    }]]
    make_schema(schemaRule)
Ejemplo n.º 4
0
def test_make_schema_headers():
    refSchema = {'CatA': {'type': 'categorical'},
                 'CatB': {'type': 'categorical'},
                 'IntA': {'type': 'count'},
                 'IntB': {'type': 'count'}}
    headers = ['IntA', 'IntB', 'CatA', 'CatB', 'Foo']
    schemaRule1 = [['Int.*', {'type': 'count'}],
                  ['Cat.*', {'type': 'categorical'}]]
    schemaRule2 = [[lambda h, v: h[0:3] == 'Cat',
                    {'type': 'categorical'}],
                   [lambda h, v: h[0:3] == 'Int',
                    {'type': 'count'}]]
    schema = make_schema(schemaRule1, headers=headers)
    assert schema == refSchema
    schema = make_schema(schemaRule2, headers=headers)
    assert schema == refSchema
Ejemplo n.º 5
0
def test_make_schema_rows():
    refSchema = {'CatA': {'type': 'categorical'},
                    'CatB': {'type': 'categorical'},
                    'IntA': {'type': 'count'},
                    'IntB': {'type': 'count'}}
    rows = [{'CatA':None, 'CatB':None, 'IntA':None, 'IntB':None, 'Foo':None}]
    schemaRule = [['Int.*', {'type': 'count'}],
                  ['Cat.*', {'type': 'categorical'}]]
    schemaRule2 = [[lambda h, v: h[0:3] == 'Cat',
                    {'type': 'categorical'}],
                   [lambda h, v: h[0:3] == 'Int',
                    {'type': 'count'}]]
    schema = make_schema(schemaRule, rows=rows)
    assert schema == refSchema
    schema = make_schema(schemaRule2, rows=rows)
    assert schema == refSchema
Ejemplo n.º 6
0
def test_make_schema_rows():
    refSchema = {
        'CatA': {
            'type': 'categorical'
        },
        'CatB': {
            'type': 'categorical'
        },
        'IntA': {
            'type': 'count'
        },
        'IntB': {
            'type': 'count'
        }
    }
    rows = [{
        'CatA': None,
        'CatB': None,
        'IntA': None,
        'IntB': None,
        'Foo': None
    }]
    schemaRule = [['Int.*', {
        'type': 'count'
    }], ['Cat.*', {
        'type': 'categorical'
    }]]
    schemaRule2 = [[lambda h, v: h[0:3] == 'Cat', {
        'type': 'categorical'
    }], [lambda h, v: h[0:3] == 'Int', {
        'type': 'count'
    }]]
    schema = make_schema(schemaRule, rows=rows)
    assert schema == refSchema
    schema = make_schema(schemaRule2, rows=rows)
    assert schema == refSchema
Ejemplo n.º 7
0
def test_make_schema_noarg2_fail():
    schemaRule = [[lambda x: x[0:4] == 'Cat',
                    {'type': 'categorical'}],
                   [lambda x: x[0:4] == 'Int',
                    {'type': 'count'}]]
    make_schema(schemaRule)
Ejemplo n.º 8
0
def test_make_schema_noarg1_fail():
    schemaRule = [['Int.*', {'type': 'count'}],
                  ['Cat.*', {'type': 'categorical'}]]
    make_schema(schemaRule)