Beispiel #1
0
 def test_hdfopen(self, F):
     attr = 'test'
     v1, v2 = 5, 6
     for group in [None, 'g']:
         with hdfopen(F, group, replace=True) as f:
             f.attrs[attr] = v1
         assert os.path.exists(F), 'failed to create HDF file'
         with hdfopen(F, group) as f:
             assert f.attrs[attr] == v1, 'attribute value wrong'
         with hdfopen(F, group, replace=True) as f:
             f.attrs[attr] = v2
         with hdfopen(F, group) as f:
             assert f.attrs[attr] == v2, 'replacing attribute failed'
Beispiel #2
0
 def test_multiple_closed_group(self, path):
     with hdfopen(path, replace=True) as h:
         for out_bin in list_test_bins():
             out_bin.to_hdf(h, group=out_bin.lid)
     for out_bin in list_test_bins():
         with HdfBin(path, out_bin.lid) as in_bin:
             assert_bin_equals(in_bin, out_bin)
Beispiel #3
0
def test_roi_roundtrip(roi, path, group=None):
    with hdfopen(path, group) as h:
        index = h.attrs['index']
        assert np.all(index == roi.keys())
        for roi_number in index:
            assert np.all(roi[roi_number] == h[str(roi_number)])
        for roi_number in index:
            assert np.all(roi[roi_number] == h[h['images'][roi_number]])
Beispiel #4
0
 def roundtrip():  # test dataframe roundtrip
     if os.path.exists(F):
         os.remove(F)
     with hdfopen(F, replace=True) as g:
         yield in_df
         pd2hdf(g, in_df)
         out_df = hdf2pd(g)
         assert_frame_equal(in_df,
                            out_df,
                            check_index_type='equiv',
                            check_column_type='equiv')
Beispiel #5
0
def test_hdr_roundtrip(hdr, path, group=None):
    with hdfopen(path, group) as h:
        for k, v in hdr.items():
            assert np.all(h.attrs[k] == hdr[k])
Beispiel #6
0
def test_adc_roundtrip(adc, path, group=None):
    with hdfopen(path, group) as h:
        csv = hdf2pd(h)
        assert h.attrs['schema'] == adc.schema._name
    assert_frame_equal(csv, adc.csv)