コード例 #1
0
ファイル: test_hdf5_stuff.py プロジェクト: uweschmitt/emzed2
def proxy_small_table(tmpdir):
    t = toTable("a", (1, 1, 2, 2, None), type_=int)
    t.addColumn("d", ("4", "4", "2", "1", None), type_=str)
    path = tmpdir.join("test.hdf5").strpath
    to_hdf5(t, path)

    prox = Hdf5TableProxy(path)
    return prox
コード例 #2
0
ファイル: test_hdf5_stuff.py プロジェクト: uweschmitt/emzed2
def test_hdf5_table_appender(table, tmpdir):
    path = tmpdir.join("test.hdf5").strpath
    to_hdf5(table, path, atomic=True)
    append_to_hdf5([table, table, table], path)

    path = tmpdir.join("test_2.hdf5").strpath
    to_hdf5(table, path, atomic=False)
    append_to_hdf5([table, table, table], path, atomic=False)
コード例 #3
0
def proxy_small_table(tmpdir):
    t = toTable("a", (1, 1, 2, 2, None), type_=int)
    t.addColumn("d", ("4", "4", "2", "1", None), type_=str)
    path = tmpdir.join("test.hdf5").strpath
    to_hdf5(t, path)

    prox = Hdf5TableProxy(path)
    return prox
コード例 #4
0
def test_hdf5_table_appender(table, tmpdir):
    path = tmpdir.join("test.hdf5").strpath
    to_hdf5(table, path, atomic=True)
    append_to_hdf5([table, table, table], path)

    path = tmpdir.join("test_2.hdf5").strpath
    to_hdf5(table, path, atomic=False)
    append_to_hdf5([table, table, table], path, atomic=False)
コード例 #5
0
ファイル: test_hdf5_stuff.py プロジェクト: uweschmitt/emzed2
def tproxy(table):

    folder = tempfile.mkdtemp()
    path = os.path.join(folder, "t.hdf5")
    to_hdf5(table, path)

    tproxy = Hdf5TableProxy(path)
    yield tproxy
    tproxy.close()
コード例 #6
0
def tproxy(table):

    folder = tempfile.mkdtemp()
    path = os.path.join(folder, "t.hdf5")
    to_hdf5(table, path)

    tproxy = Hdf5TableProxy(path)
    yield tproxy
    tproxy.close()
コード例 #7
0
ファイル: test_hdf5_stuff.py プロジェクト: uweschmitt/emzed2
def test_write_unicode(tmpdir, regtest):

    table = toTable("a", ("x", None, u"", "", u"ccccäää##c"), type_=unicode)
    table.addColumn("b", ("x", "asbcder", None, None, ""), type_=str)
    table.addColumn("c", ("x", "asbcder", 1, (1,), ""), type_=object)
    path = tmpdir.join("t.hdf5").strpath
    to_hdf5(table, path)
    prox = Hdf5TableProxy(path)
    print(prox.toTable(), file=regtest)
    print(prox.reader.get_col_values("a"), file=regtest)
    print(prox.reader.get_col_values("b"), file=regtest)
    print([i.load() for i in prox.reader.get_col_values("c")], file=regtest)
コード例 #8
0
def test_write_unicode(tmpdir, regtest):

    table = toTable("a", ("x", None, u"", "", u"ccccäää##c"), type_=unicode)
    table.addColumn("b", ("x", "asbcder", None, None, ""), type_=str)
    table.addColumn("c", ("x", "asbcder", 1, (1, ), ""), type_=object)
    path = tmpdir.join("t.hdf5").strpath
    to_hdf5(table, path)
    prox = Hdf5TableProxy(path)
    print(prox.toTable(), file=regtest)
    print(prox.reader.get_col_values("a"), file=regtest)
    print(prox.reader.get_col_values("b"), file=regtest)
    print([i.load() for i in prox.reader.get_col_values("c")], file=regtest)
コード例 #9
0
ファイル: test_hdf5_stuff.py プロジェクト: uweschmitt/emzed2
def test_round_trip_objects(tmpdir, regtest):
    # test roundtrip:
    col = [{i: i + 1} for i in range(5)]
    t0 = toTable("dicts", col, type_=object)

    col = [{i: i + 2} for i in range(5)]
    t0.addColumn("dicts_1", col, type_=object)
    t0.addColumn("strs", map(str, range(5)), type_=str)
    t0.addColumn("strs_1", t0.strs * 3 + "_x", type_=str)

    print(t0, file=regtest)
    path = tmpdir.join("test.hdf5").strpath
    to_hdf5(t0, path)
    tproxy = Hdf5TableProxy(path)

    tback = tproxy.toTable()
    print(tback, file=regtest)
コード例 #10
0
def test_round_trip_objects(tmpdir, regtest):
    # test roundtrip:
    col = [{i: i + 1} for i in range(5)]
    t0 = toTable("dicts", col, type_=object)

    col = [{i: i + 2} for i in range(5)]
    t0.addColumn("dicts_1", col, type_=object)
    t0.addColumn("strs", map(str, range(5)), type_=str)
    t0.addColumn("strs_1", t0.strs * 3 + "_x", type_=str)

    print(t0, file=regtest)
    path = tmpdir.join("test.hdf5").strpath
    to_hdf5(t0, path)
    tproxy = Hdf5TableProxy(path)

    tback = tproxy.toTable()
    print(tback, file=regtest)