Exemplo n.º 1
0
def test_hdf5writer_none():
    f = Frame()
    f.n = None
    f.writer = writers.hdf5writer()
    with pytest.raises(ValueError):
        f.writeoutput(0)
    f.n = [1, None]
    with pytest.raises(ValueError):
        f.writeoutput(1)
    f.n = (1, None)
    with pytest.raises(ValueError):
        f.writeoutput(2)
    shutil.rmtree(f.writer.datadir)
Exemplo n.º 2
0
def test_hdf5writer_dict():
    f = Frame()
    f.n = {1: 1}
    f.writer = writers.hdf5writer()
    with pytest.raises(NotImplementedError):
        f.writeoutput(0)
    shutil.rmtree(f.writer.datadir)
Exemplo n.º 3
0
def test_hdf5writer_list():
    f = Frame()
    f.n = [1, 1]
    f.writer = writers.hdf5writer()
    f.writeoutput(0)
    f.writeoutput(1)
    data0000 = f.writer.read.output(0)
    assert np.all(data0000.n == [1, 1])
    n = f.writer.read.sequence("n")
    assert np.all(n == [[1, 1], [1, 1]])
    data = f.writer.read.all()
    assert np.all(data.n == [[1, 1], [1, 1]])
    shutil.rmtree(f.writer.datadir)
Exemplo n.º 4
0
def test_hdf5writer_single_value_array():
    f = Frame()
    f.n = np.array(1)
    f.writer = writers.hdf5writer()
    f.writeoutput(0)
    f.writeoutput(1)
    data0000 = f.writer.read.output(0)
    assert data0000.n == 1
    n = f.writer.read.sequence("n")
    assert np.all(n == [1, 1])
    data = f.writer.read.all()
    assert np.all(data.n == [1, 1])
    shutil.rmtree(f.writer.datadir)