예제 #1
0
def test_data_error():
    rtdc_file = tempfile.mktemp(suffix=".rtdc",
                                prefix="dclab_test_error_")
    with pytest.raises(ValueError, match="unknown"):
        RTDCWriter(rtdc_file, mode="unknown")

    hw = RTDCWriter(rtdc_file)
    with pytest.raises(ValueError, match="area_undefined"):
        hw.store_feature("area_undefined", np.linspace(100.7, 110.9, 100))

    with pytest.raises(ValueError, match="fl_unknown"):
        hw.store_feature("trace", {"fl_unknown": np.arange(10)})
예제 #2
0
def test_ic_fmt_hdf5_image_bg():
    h5path = retrieve_data("fmt-hdf5_fl_2018.zip")
    # add a fake image_bg column
    with h5py.File(h5path, "a") as h5:
        image_bg = h5["events"]["image"][:] // 2
        hw = RTDCWriter(h5)
        hw.store_feature("image_bg", image_bg)
        del h5["events/image_bg"].attrs["CLASS"]
    with check.IntegrityChecker(h5path) as ic:
        cues = ic.check_fmt_hdf5()
    assert cues[0].category == "format HDF5"
    assert cues[0].msg == "HDF5: '/image_bg': missing attribute 'CLASS'"
    assert cues[0].level == "alert"