def test_discover(): with tmpfile('hdf5') as fn: df.to_hdf(fn, '/a/b/data') df.to_hdf(fn, '/a/b/data2') df.to_hdf(fn, '/a/data') hdf = pd.HDFStore(fn) assert discover(hdf) == discover({'a': {'b': {'data': df, 'data2': df}, 'data': df}})
def test_fixed_shape(): with tmpfile('.hdf5') as fn: df.to_hdf(fn, 'foo') r = resource('hdfstore://' + fn + '::/foo') assert isinstance(r.shape, list) assert discover(r).shape == (len(df), ) r.parent.close()
def test_discover(): with tmpfile('hdf5') as fn: df.to_hdf(fn, '/a/b/data') df.to_hdf(fn, '/a/b/data2') df.to_hdf(fn, '/a/data') hdf = pd.HDFStore(fn) assert discover(hdf) == discover( {'a': { 'b': { 'data': df, 'data2': df }, 'data': df }})
def test_into_resource(): with tmpfile('.hdf5') as fn: d = into('hdfstore://' + fn + '::/x', df) assert discover(d) == discover(df) assert eq(into(pd.DataFrame, d), df)
def test_append(): with file(df) as (fn, f, dset): append(dset, df) append(dset, df) assert discover(dset).shape == (len(df) * 3,)
def test_discover(): with file(df) as (fn, f, dset): assert str(discover(dset)) == str(discover(df)) assert str(discover(f)) == str(discover({'data': df}))
def test_fixed_shape(): with tmpfile('.hdf5') as fn: df.to_hdf(fn, 'foo') r = resource('hdfstore://'+fn+'::/foo') assert isinstance(r.shape, list) assert discover(r).shape == (len(df),)
def test_append_other(): with tmpfile('.hdf5') as fn: x = into(np.ndarray, df) dset = into('hdfstore://'+fn+'::/data', x) assert discover(dset) == discover(x)
def test_append_chunks(): with file(df) as (fn, f, dset): append(dset, chunks(pd.DataFrame)([df, df])) assert discover(dset).shape[0] == len(df) * 3
def test_into_resource(): with tmpfile('.hdf5') as fn: d = into('hdfstore://' + fn + '::/x', df) assert discover(d) == discover(df) assert eq(into(pd.DataFrame, d), df) d.parent.close()
def test_append(): with file(df) as (fn, f, dset): append(dset, df) append(dset, df) assert discover(dset).shape == (len(df) * 3, )
def test_discover(): with file(df) as (fn, f, dset): assert str(discover(dset)) == str(discover(df)) assert str(discover(f)) == str(discover({'data': df}))
def test_append_other(): with tmpfile('.hdf5') as fn: x = into(np.ndarray, df) dset = into('hdfstore://' + fn + '::/data', x) assert discover(dset) == discover(df) dset.parent.close()
def test_append_chunks(): with file(df) as (fn, f, dset): append(dset, chunks(pd.DataFrame)([df, df])) assert discover(dset).shape[0] == len(df) * 3