Exemplo n.º 1
0
def test_missing_file():
    pytest.importorskip("nptdms")
    h5path = retrieve_data("fmt-tdms_2fl-no-image_2017.zip")
    h5path.with_name("M1_para.ini").unlink()
    try:
        check_dataset(h5path)
    except fmt_tdms.IncompleteTDMSFileFormatError:
        pass
    else:
        assert False
Exemplo n.º 2
0
def test_exact():
    pytest.importorskip("nptdms")
    h5path = retrieve_data("fmt-tdms_2fl-no-image_2017.zip")
    viol, aler, info = check_dataset(h5path)
    known_viol = [
        "Metadata: Missing key [fluorescence] 'channel count'",
        "Metadata: Missing key [fluorescence] 'channels installed'",
        "Metadata: Missing key [fluorescence] 'laser count'",
        "Metadata: Missing key [fluorescence] 'lasers installed'",
        "Metadata: Missing key [fluorescence] 'samples per event'",
    ]
    known_aler = [
        "Metadata: Missing key [fluorescence] 'channel 1 name'",
        "Metadata: Missing key [fluorescence] 'channel 2 name'",
        "Metadata: Missing key [online_contour] 'no absdiff'",
        "Metadata: Missing key [setup] 'identifier'",
        "Metadata: Missing key [setup] 'module composition'",
        "Negative value for feature(s): fl2_max",
    ]
    known_info = [
        'Compression: None',
        'Data file format: tdms',
        'Fluorescence: True',
    ]
    assert set(viol) == set(known_viol)
    assert set(aler) == set(known_aler)
    assert set(info) == set(known_info)
Exemplo n.º 3
0
def test_basic():
    h5path = retrieve_data("fmt-hdf5_fl_2017.zip")
    viol, aler, info = check_dataset(h5path)
    # Features: Unknown key 'ncells'
    # Metadata: Mismatch [imaging] 'roi size x' and feature image (50 vs 90)
    # Metadata: Mismatch [imaging] 'roi size y' and feature image (90 vs 50)
    # Metadata: Missing key [fluorescence] 'channels installed'
    # Metadata: Missing key [fluorescence] 'laser count'
    # Metadata: Missing key [fluorescence] 'lasers installed'
    # Metadata: Missing key [fluorescence] 'samples per event'
    # Metadata: fluorescence channel count inconsistent
    assert len(viol) == 8
    # "HDF5: '/image': attribute 'CLASS' should be fixed-length ASCII string",
    # "HDF5: '/image': attribute 'IMAGE_SUBCLASS' should be fixed-length ...
    # "HDF5: '/image': attribute 'IMAGE_VERSION' should be fixed-length ...
    # "Metadata: Flow rates don't add up (sh 0.6 + sam 0.1 != channel 0.16)",
    # "Metadata: Flow rates don't add up (sh 0.6 + sam 0.1 != channel 0.16)",
    # "Metadata: Flow rates don't add up (sh 0.6 + sam 0.1 != channel 0.16)",
    # "Metadata: Missing key [fluorescence] 'channel 1 name'",
    # "Metadata: Missing key [fluorescence] 'channel 2 name'",
    # "Metadata: Missing key [fluorescence] 'channel 3 name'",
    # "Metadata: Missing key [setup] 'identifier'",
    # "Metadata: Missing section 'online_contour'"
    # "UnknownConfigurationKeyWarning: Unknown key 'exposure time' ...",
    # "UnknownConfigurationKeyWarning: Unknown key 'flash current' ...",
    # "UserWarning: Type of confguration key [fluorescence]: sample rate ...",
    # "UserWarning: Type of confguration key [imaging]: roi position x ...",
    # "UserWarning: Type of confguration key [imaging]: roi position y ..."]
    assert len(aler) == 16
    assert "Data file format: hdf5" in info
    assert "Fluorescence: True" in info
    assert "Compression: Partial (1 of 25)" in info
Exemplo n.º 4
0
def test_wrong_samples_per_event():
    pytest.importorskip("nptdms")
    h5path = retrieve_data("fmt-tdms_2fl-no-image_2017.zip")
    with h5path.with_name("M1_para.ini").open("a") as fd:
        fd.write("Samples Per Event = 10\n")
    msg = "Metadata: wrong number of samples per event: fl1_median " \
          + "(expected 10, got 566)"
    viol, _, _ = check_dataset(h5path)
    assert msg in viol
Exemplo n.º 5
0
def test_temperature():
    # there are probably a million things wrong with this dataset, but
    # we are only looking for the temperature thing
    ddict = example_data_dict(size=8472, keys=["area_um", "deform", "temp"])
    ds = new_dataset(ddict)
    sstr = "Metadata: Missing key [setup] 'temperature', " \
           + "because the 'temp' feature is given"
    _, aler, _ = check_dataset(ds)
    assert sstr in aler
Exemplo n.º 6
0
def test_complete():
    h5path = retrieve_data("fmt-hdf5_fl_2018.zip")
    viol, aler, info = check_dataset(h5path)
    assert len(viol) == 0
    # [fluorescence]: sample rate should be <class 'numbers.Integral'>
    # [imaging]: roi position x should be <class 'numbers.Integral'>
    # [imaging]: roi position y should be <class 'numbers.Integral'>
    assert len(aler) == 3
    assert "Data file format: hdf5" in info
    assert "Fluorescence: True" in info
Exemplo n.º 7
0
def test_no_fluorescence():
    pytest.importorskip("nptdms")
    h5path = retrieve_data("fmt-tdms_minimal_2016.zip")
    _, _, info = check_dataset(h5path)
    known_info = [
        'Compression: None',
        'Data file format: tdms',
        'Fluorescence: False',
    ]
    assert set(info) == set(known_info)
Exemplo n.º 8
0
def test_invalid_medium():
    pytest.importorskip("nptdms")
    h5path = retrieve_data("fmt-tdms_minimal_2016.zip")
    para = h5path.with_name("M1_para.ini")
    cfg = para.read_text().split("\n")
    cfg.insert(3, "Buffer Medium = unknown_bad!")
    para.write_text("\n".join(cfg))
    viol, _, _ = check_dataset(h5path)
    # changed in 0.29.1: medium can now be an arbitrary string
    # except for an empty string.
    assert "Metadata: Invalid value [setup] medium: 'unknown_bad!'" not in viol
Exemplo n.º 9
0
def test_complete_user_metadata():
    """Setting any user metadata is allowed"""
    h5path = retrieve_data("fmt-hdf5_fl_2018.zip")
    metadata = {
        "channel area": 100.5,
        "inlet": True,
        "n_constrictions": 3,
        "channel information": "other information"
    }
    with new_dataset(h5path) as ds:
        ds.config.update({"user": metadata})
        expath = h5path.with_name("exported.rtdc")
        ds.export.hdf5(expath, features=ds.features_innate)
        viol, aler, info = check_dataset(ds)
        assert len(viol) == 0
        assert len(aler) == 0
        assert "Data file format: hdf5" in info
        assert "Fluorescence: True" in info
Exemplo n.º 10
0
def test_load_with():
    pytest.importorskip("nptdms")
    h5path = retrieve_data("fmt-tdms_minimal_2016.zip")
    known_aler = [
        "Metadata: Missing key [setup] 'flow rate sample'",
        "Metadata: Missing key [setup] 'flow rate sheath'",
        "Metadata: Missing key [setup] 'identifier'",
        "Metadata: Missing key [setup] 'module composition'",
        "Metadata: Missing key [setup] 'software version'",
    ]
    known_viol = [
        "Features: wrong event count: 'contour' (14 of 156)",
        "Features: wrong event count: 'mask' (14 of 156)",
        "Metadata: Missing key [setup] 'medium'",
    ]
    with new_dataset(h5path) as ds:
        viol, aler, _ = check_dataset(ds)
        assert set(viol) == set(known_viol)
        assert set(aler) == set(known_aler)
def test_basic():
    h5path = retrieve_data("rtdc_data_hdf5_contour_image_trace.zip")
    viol, aler, info = check_dataset(h5path)
    # Features: Unknown key 'ncells'
    # Metadata: Missing key [fluorescence] 'channels installed'
    # Metadata: Missing key [fluorescence] 'laser count'
    # Metadata: Missing key [fluorescence] 'lasers installed'
    # Metadata: Missing key [fluorescence] 'samples per event'
    # Metadata: Unknown key [imaging] 'exposure time'
    # Metadata: Unknown key [imaging] 'flash current'
    # Metadata: Unknown key [setup] 'temperature'
    # Metadata: fluorescence channel count inconsistent
    assert len(viol) == 9
    # Metadata: Missing key [setup] identifier'
    # Metadata: Missing section 'online_contour'
    # "HDF5: '/image': attribute 'CLASS' should be fixed-length ASCII string",
    # "HDF5: '/image': attribute 'IMAGE_SUBCLASS' should be fixed-length ...",
    # "HDF5: '/image': attribute 'IMAGE_VERSION' should be fixed-length ...",
    assert len(aler) == 5
    assert "Data file format: hdf5" in info
    assert "Fluorescence: True" in info
    cleanup()