예제 #1
0
def setupTable():
    names = "int long float str object array".split()
    types = [
        int,
        long,
        float,
        str,
        object,
        np.ndarray,
    ]
    formats = ["%3d", "%d", "%.3f", "%s", "%r", "'array(%r)' % o.shape"]

    row1 = [1, 12323L, 1.0, "hi", {1: 1}, np.array((1, 2, 3))]
    row2 = [2, 22323L, 2.0, "hi2", [
        2,
        3,
    ], np.array(((2, 3, 4), (1, 2, 3)))]
    row3 = [
        3, 32323L, 3.0, "hi3", (3, ),
        np.array(((3, 3, 4, 5), (1, 2, 3, 4)))
    ]

    rows = [row1, row2, row3]
    t = Table(names, types, formats, rows, "testtabelle", meta=dict(why=42))
    t = t.extractColumns("int", "float", "str")
    t.addEnumeration()
    t._name = "t"
    t._print()
    return t
예제 #2
0
def setupTable():
    names="int long float str object array".split()
    types = [int, long, float, str, object, np.ndarray,]
    formats = [ "%3d", "%d", "%.3f", "%s", "%r", "'array(%r)' % o.shape" ]

    row1 = [ 1, 12323L, 1.0, "hi", { 1: 1 },  np.array((1,2,3)) ]
    row2 = [ 2, 22323L, 2.0, "hi2", [2,3,], np.array(((2,3,4),(1,2,3))) ]
    row3 = [ 3, 32323L, 3.0, "hi3", (3,) , np.array(((3,3,4,5),(1,2,3,4))) ]

    rows = [row1, row2, row3]
    t=Table(names, types, formats, rows, "testtabelle", meta=dict(why=42))
    t = t.extractColumns("int", "float", "str")
    t.addEnumeration()
    t._name = "t"
    t._print()
    return t
예제 #3
0
파일: testTable.py 프로젝트: burlab/emzed
def testIfThenElse():
    t = Table(["a", "b", "c"], [str, int, int], ["%s", "%d", "%d"],[])
    t.rows.append(["0", 1, 2])
    t.rows.append([None, 2, 1])
    t._print()
    t.addColumn("x", (t.a.isNotNone()).thenElse(t.b, t.c))
    assert t.getColNames()==["a", "b", "c", "x"]
    print
    t._print()
    t.addColumn("y", (t.a.isNotNone()).thenElse("ok", "not ok"))
    t._print()
    assert t.y.values == ["ok", "not ok"]
예제 #4
0
def testIfThenElse():
    t = Table(["a", "b", "c"], [str, int, int], ["%s", "%d", "%d"], [])
    t.rows.append(["0", 1, 2])
    t.rows.append([None, 2, 1])
    t._print()
    t.addColumn("x", (t.a.isNotNone()).thenElse(t.b, t.c))
    assert t.getColNames() == ["a", "b", "c", "x"]
    print
    t._print()
    t.addColumn("y", (t.a.isNotNone()).thenElse("ok", "not ok"))
    t._print()
    assert t.y.values == ["ok", "not ok"]