def test_logs(): path_in = retrieve_data("fmt-hdf5_mask-contour_2018.zip") with new_dataset(path_in) as ds: assert not ds.logs # write some logs with h5py.File(path_in, "a") as h5: hw = rtdc_dataset.RTDCWriter(h5) hw.store_log("test_log", ["peter", "hans"]) with new_dataset(path_in) as ds: assert ds.logs assert ds.logs["test_log"][0] == "peter" # remove logs with h5py.File(path_in, "a") as h5: del h5["logs"] with new_dataset(path_in) as ds: assert not ds.logs try: ds.logs["test_log"] except KeyError: # no log data pass
def test_image_bg(): path = retrieve_data("fmt-hdf5_fl_2017.zip") # add a fake image_bg column with rtdc_dataset.RTDCWriter(path) as hw: image_bg = hw.h5file["events"]["image"][:] // 2 hw.store_feature("image_bg", image_bg) with new_dataset(path) as ds: for ii in range(len(ds)): assert np.all(ds["image"][ii] // 2 == ds["image_bg"][ii])
def test_repack_strip_logs(): path_in = retrieve_data("fmt-hdf5_mask-contour_2018.zip") # same directory (will be cleaned up with path_in) path_out = path_in.with_name("repacked.rtdc") # write some logs with h5py.File(path_in, "a") as h5: hw = rtdc_dataset.RTDCWriter(h5) hw.store_log("test_log", ["peter", "hans"]) cli.repack(path_out=path_out, path_in=path_in, strip_logs=True) with new_dataset(path_out) as dsj, new_dataset(path_in) as ds0: assert ds0.logs assert not dsj.logs