def test_union():
    result = compute(union(t, t), x)
    assert result.shape == (x.shape[0] * 2,)
    assert eq(result[:5], x)
    assert eq(result[5:], x)
    result = compute(union(t.id, t.id), x)
    assert eq(result, np.array([1, 2, 3, 4, 5, 1, 2, 3, 4, 5]))
Example #2
0
def test_union():
    result = compute(union(t, t), x)
    assert result.shape == (x.shape[0] * 2, )
    assert eq(result[:5], x)
    assert eq(result[5:], x)
    result = compute(union(t.id, t.id), x)
    assert eq(result, np.array([1, 2, 3, 4, 5, 1, 2, 3, 4, 5]))
Example #3
0
def test_union():
    schema = '{x: int, y: int, z: int}'
    a = TableSymbol('a', schema)
    b = TableSymbol('b', schema)
    c = TableSymbol('c', schema)

    u = union(a, b, c)
    assert u.schema == a.schema

    assert raises(Exception,
                  lambda: union(a, TableSymbol('q', '{name: string}')))
Example #4
0
def test_union():
    schema = '{x: int, y: int, z: int}'
    a = TableSymbol('a', schema)
    b = TableSymbol('b', schema)
    c = TableSymbol('c', schema)

    u = union(a, b, c)
    assert u.schema == a.schema

    assert raises(Exception,
                  lambda: union(a, TableSymbol('q', '{name: string}')))
Example #5
0
def test_union():
    L1 = [['Alice', 100, 1], ['Bob', 200, 2], ['Alice', 50, 3]]
    L2 = [['Alice', 100, 4], ['Bob', 200, 5], ['Alice', 50, 6]]
    L3 = [['Alice', 100, 7], ['Bob', 200, 8], ['Alice', 50, 9]]

    t1 = Symbol('t1', 'var * {name: string, amount: int, id: int}')
    t2 = Symbol('t2', 'var * {name: string, amount: int, id: int}')
    t3 = Symbol('t3', 'var * {name: string, amount: int, id: int}')

    expr = union(t1, t2, t3)

    result = list(compute(expr, {t1: L1, t2: L2, t3: L3}))

    assert result == L1 + L2 + L3
Example #6
0
def test_union():
    L1 = [['Alice', 100, 1],
          ['Bob', 200, 2],
          ['Alice', 50, 3]]
    L2 = [['Alice', 100, 4],
          ['Bob', 200, 5],
          ['Alice', 50, 6]]
    L3 = [['Alice', 100, 7],
          ['Bob', 200, 8],
          ['Alice', 50, 9]]

    t1 = TableSymbol('t1', '{name: string, amount: int, id: int}')
    t2 = TableSymbol('t2', '{name: string, amount: int, id: int}')
    t3 = TableSymbol('t3', '{name: string, amount: int, id: int}')

    expr = union(t1, t2, t3)

    result = list(compute(expr, {t1: L1, t2: L2, t3: L3}))

    assert result == L1 + L2 + L3
Example #7
0
def test_union():

    d1 = DataFrame([['Alice', 100, 1],
                    ['Bob', 200, 2],
                    ['Alice', 50, 3]], columns=['name', 'amount', 'id'])
    d2 = DataFrame([['Alice', 100, 4],
                    ['Bob', 200, 5],
                    ['Alice', 50, 6]], columns=['name', 'amount', 'id'])
    d3 = DataFrame([['Alice', 100, 7],
                    ['Bob', 200, 8],
                    ['Alice', 50, 9]], columns=['name', 'amount', 'id'])

    t1 = TableSymbol('t1', '{name: string, amount: int, id: int}')
    t2 = TableSymbol('t2', '{name: string, amount: int, id: int}')
    t3 = TableSymbol('t3', '{name: string, amount: int, id: int}')

    expr = union(t1, t2, t3)

    result = compute(expr, {t1: d1, t2: d2, t3: d3})

    assert np.all(result.columns == d1.columns)
    assert set(result['id']) == set(range(1, 10))
Example #8
0
def test_union():

    d1 = DataFrame([['Alice', 100, 1],
                    ['Bob', 200, 2],
                    ['Alice', 50, 3]], columns=['name', 'amount', 'id'])
    d2 = DataFrame([['Alice', 100, 4],
                    ['Bob', 200, 5],
                    ['Alice', 50, 6]], columns=['name', 'amount', 'id'])
    d3 = DataFrame([['Alice', 100, 7],
                    ['Bob', 200, 8],
                    ['Alice', 50, 9]], columns=['name', 'amount', 'id'])

    t1 = Symbol('t1', 'var * {name: string, amount: int, id: int}')
    t2 = Symbol('t2', 'var * {name: string, amount: int, id: int}')
    t3 = Symbol('t3', 'var * {name: string, amount: int, id: int}')

    expr = union(t1, t2, t3)

    result = compute(expr, {t1: d1, t2: d2, t3: d3})

    assert np.all(result.columns == d1.columns)
    assert set(result['id']) == set(range(1, 10))
Example #9
0
def test_union_1d():
    t = Symbol('t', 'var * int')
    x = np.array([1, 2, 3])
    assert eq(compute(union(t, t), x), np.array([1, 2, 3, 1, 2, 3]))
Example #10
0
def test_union_1d():
    t = TableSymbol('t', '{x: int}', iscolumn=True)
    x = np.array([1, 2, 3])
    assert eq(compute(union(t, t), x), np.array([1, 2, 3, 1, 2, 3]))
Example #11
0
def test_union_1d():
    t = TableSymbol('t', 'int')
    x = np.array([1, 2, 3])
    assert eq(compute(union(t, t), x), np.array([1, 2, 3, 1, 2, 3]))