def test_table_resource(): with tmpfile('csv') as filename: csv = CSV(filename, 'w', schema='{x: int, y: int}') csv.extend([[1, 2], [10, 20]]) t = Table(filename) assert isinstance(t.data, CSV) assert list(compute(t)) == list(csv)
def test_compute(): assert list(compute(t['amount'] + 1)) == [101, 201]
def test_compute(): assert compute(t) == data
def test_resources_fail(): t = TableSymbol('t', '{x:int, y:int}') d = t[t['x'] > 100] with pytest.raises(ValueError): compute(d)
def test_into_nd_array_column_failure(): tble = Table(L, columns=['id', 'name', 'balance']) expr = tble[tble['balance'] < 0] colarray = into(nd.array, expr) assert len(list(compute(expr))) == len(colarray)
def test_into_nd_array_selection(): tble = Table(L, columns=['id', 'name', 'balance']) expr = tble[tble['balance'] < 0] selarray = into(nd.array, expr) assert len(list(compute(expr))) == len(selarray)
def test_into_np_ndarray_column(): tble = Table(L, columns=['id', 'name', 'balance']) expr = tble[tble['balance'] < 0]['name'] colarray = into(np.ndarray, expr) assert len(list(compute(expr))) == len(colarray)