Exemplo n.º 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
Exemplo n.º 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