当前位置: 首页>>代码示例>>Python>>正文


Python expr.Symbol类代码示例

本文整理汇总了Python中blaze.expr.Symbol的典型用法代码示例。如果您正苦于以下问题:Python Symbol类的具体用法?Python Symbol怎么用?Python Symbol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Symbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_relabel_join

def test_relabel_join():
    names = Symbol('names', 'var * {first: string, last: string}')

    siblings = join(names.relabel({'last': 'left'}),
                    names.relabel({'last': 'right'}), 'first')

    assert siblings.fields == ['first', 'left', 'right']
开发者ID:EGQM,项目名称:blaze,代码行数:7,代码来源:test_symbol.py

示例2: test_by_columns

def test_by_columns():
    t = Symbol('t', 'var * {name: string, amount: int32, id: int32}')

    assert len(by(t['id'], total=t['amount'].sum()).fields) == 2
    assert len(by(t['id'], count=t['id'].count()).fields) == 2
    print(by(t, count=t.count()).fields)
    assert len(by(t, count=t.count()).fields) == 4
开发者ID:EGQM,项目名称:blaze,代码行数:7,代码来源:test_symbol.py

示例3: test_subterms

def test_subterms():
    a = Symbol('a', 'var * {x: int, y: int, z: int}')
    assert list(a._subterms()) == [a]
    assert set(a['x']._subterms()) == set([a, a['x']])
    assert set(a['x'].map(inc, 'int')._subterms()) == \
            set([a, a['x'], a['x'].map(inc, 'int')])
    assert a in set((a['x'] + 1)._subterms())
开发者ID:EGQM,项目名称:blaze,代码行数:7,代码来源:test_symbol.py

示例4: test_distinct_name

def test_distinct_name():
    t = Symbol('t', 'var * {id: int32, name: string}')

    assert t.name.isidentical(t['name'])
    assert t.distinct().name.isidentical(t.distinct()['name'])
    assert t.id.distinct()._name == 'id'
    assert t.name._name == 'name'
开发者ID:EGQM,项目名称:blaze,代码行数:7,代码来源:test_symbol.py

示例5: test_keepdims

def test_keepdims():
    x = Symbol('x', '5 * 3 * float32')
    assert x.sum(axis=0, keepdims=True).dshape == dshape('1 * 3 * float32')
    assert x.sum(axis=1, keepdims=True).dshape == dshape('5 * 1 * float32')
    assert x.sum(axis=(0, 1), keepdims=True).dshape == dshape('1 * 1 * float32')

    assert x.std(axis=0, keepdims=True).shape == (1, 3)
开发者ID:Back2Basics,项目名称:blaze,代码行数:7,代码来源:test_reductions.py

示例6: test_traverse

def test_traverse():
    t = Symbol('t', 'var * {name: string, amount: int}')
    assert t in list(t._traverse())

    expr = t.amount.sum()
    trav = list(expr._traverse())
    assert builtins.any(t.amount.isidentical(x) for x in trav)
开发者ID:EGQM,项目名称:blaze,代码行数:7,代码来源:test_symbol.py

示例7: test_nelements_array

def test_nelements_array():
    t = Symbol('t', '5 * 4 * 3 * float64')
    x = np.random.randn(*t.shape)
    result = compute(t.nelements(axis=(0, 1)), x)
    np.testing.assert_array_equal(result, np.array([20, 20, 20]))

    result = compute(t.nelements(axis=1), x)
    np.testing.assert_array_equal(result, 4 * np.ones((5, 3)))
开发者ID:Back2Basics,项目名称:blaze,代码行数:8,代码来源:test_numpy_compute.py

示例8: test_symbol_projection_failures

def test_symbol_projection_failures():
    t = Symbol('t', '10 * {name: string, amount: int}')
    with pytest.raises(ValueError):
        t._project(['name', 'id'])
    with pytest.raises(AttributeError):
        t.foo
    with pytest.raises(TypeError):
        t._project(t.dshape)
开发者ID:EGQM,项目名称:blaze,代码行数:8,代码来源:test_symbol.py

示例9: test_Distinct

def test_Distinct():
    t = Symbol('t', 'var * {name: string, amount: int32}')
    r = distinct(t['name'])
    print(r.dshape)
    assert r.dshape  == dshape('var * string')
    assert r._name == 'name'

    r = t.distinct()
    assert r.dshape  == t.dshape
开发者ID:EGQM,项目名称:blaze,代码行数:9,代码来源:test_symbol.py

示例10: test_sort

def test_sort():
    t = Symbol('t', 'var * {name: string, amount: int32, id: int32}')
    s = t.sort('amount', ascending=True)
    print(str(s))
    assert eval(str(s)).isidentical(s)

    assert s.schema == t.schema

    assert t['amount'].sort().key == 'amount'
开发者ID:EGQM,项目名称:blaze,代码行数:9,代码来源:test_symbol.py

示例11: test_like

def test_like():
    t = Symbol('t', 'var * {name: string, city: string}')
    data = [('Alice Smith', 'New York'),
            ('Bob Smith', 'Chicago'),
            ('Alice Walker', 'LA')]

    assert list(compute(t.like(name='Alice*'), data)) == [data[0], data[2]]
    assert list(compute(t.like(name='lice*'), data)) == []
    assert list(compute(t.like(name='*Smith*'), data)) == [data[0], data[1]]
    assert list(compute(t.like(name='*Smith*', city='New York'), data)) == [data[0]]
开发者ID:Back2Basics,项目名称:blaze,代码行数:10,代码来源:test_python_compute.py

示例12: test_serializable

def test_serializable():
    t = Symbol('t', 'var * {id: int, name: string, amount: int}')
    import pickle
    t2 = pickle.loads(pickle.dumps(t))

    assert t.isidentical(t2)

    s = Symbol('t', 'var * {id: int, city: string}')
    expr = join(t[t.amount < 0], s).sort('id').city.head()
    expr2 = pickle.loads(pickle.dumps(expr))

    assert expr.isidentical(expr2)
开发者ID:EGQM,项目名称:blaze,代码行数:12,代码来源:test_symbol.py

示例13: test_length

def test_length():
    t = Symbol('t', '10 * {name: string, amount: int}')
    s = Symbol('s', 'var * {name:string, amount:int}')
    assert t.dshape == dshape('10 * {name: string, amount: int}')
    assert len(t) == 10
    assert len(t.name) == 10
    assert len(t[['name']]) == 10
    assert len(t.sort('name')) == 10
    assert len(t.head(5)) == 5
    assert len(t.head(50)) == 10
    with pytest.raises(ValueError):
        len(s)
开发者ID:EGQM,项目名称:blaze,代码行数:12,代码来源:test_symbol.py

示例14: test_leaves

def test_leaves():
    t = Symbol('t', 'var * {id: int32, name: string}')
    v = Symbol('v', 'var * {id: int32, city: string}')
    x = symbol('x', 'int32')

    assert t._leaves() == [t]
    assert t.id._leaves() == [t]
    assert by(t.name, count=t.id.nunique())._leaves() == [t]
    assert join(t, v)._leaves() == [t, v]
    assert join(v, t)._leaves() == [v, t]

    assert (x + 1)._leaves() == [x]
开发者ID:EGQM,项目名称:blaze,代码行数:12,代码来源:test_symbol.py

示例15: test_relabel

def test_relabel():
    t = Symbol('t', 'var * {name: string, amount: int32, id: int32}')

    rl = t.relabel({'name': 'NAME', 'id': 'ID'})
    rlc = t['amount'].relabel({'amount': 'BALANCE'})

    assert eval(str(rl)).isidentical(rl)

    print(rl.fields)
    assert rl.fields == ['NAME', 'amount', 'ID']

    assert not isscalar(rl.dshape.measure)
    assert isscalar(rlc.dshape.measure)
开发者ID:EGQM,项目名称:blaze,代码行数:13,代码来源:test_symbol.py


注:本文中的blaze.expr.Symbol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。