예제 #1
0
def test_extract_header_items_errors(loaded_lab_file):
    header, channels, chtrig = loaded_lab_file
    # test file without header
    with raises(AttributeError) as errorinfo:
        io.extract_header_items(channels, header=[])
    assert 'without header' in str(errorinfo.value)
    # test when header is not valid
    with raises(AttributeError) as errorinfo:
        io.extract_header_items(channels, header=['hello', 'bye'])
    assert 'supported yet for txt files' in str(errorinfo.value)
예제 #2
0
def test_generate_blueprint_notime(notime_lab_file):
    chtrig = 0
    header, channels = io.read_header_and_channels(notime_lab_file)
    interval, orig_units, orig_names = io.extract_header_items(
        channels, header)
    phys_obj = io.generate_blueprint(channels, chtrig, interval, orig_units,
                                     orig_names)
    assert len(phys_obj.timeseries) == len(channels[0]) + 1
예제 #3
0
def test_generate_blueprint_for_labchart(loaded_lab_file, units, expected):
    header, channels, chtrig = loaded_lab_file
    header[0][1] = units
    interval, orig_units, orig_names = io.extract_header_items(
        channels, header)
    phys_obj = io.generate_blueprint(channels, chtrig, interval, orig_units,
                                     orig_names)
    assert math.isclose(phys_obj.freq[0], expected)
예제 #4
0
def test_multifreq(loaded_lab_file):
    header, channels, chtrig = loaded_lab_file
    interval, orig_units, orig_names = io.extract_header_items(
        channels, header)
    phys_obj = io.generate_blueprint(channels, chtrig, interval, orig_units,
                                     orig_names)
    new_freq = io.check_multifreq(phys_obj.timeseries,
                                  [phys_obj.freq[0]] * len(phys_obj.freq))
    assert new_freq[-3:] == [100, 40, 500]
예제 #5
0
def test_generate_blueprint_for_acq(loaded_acq_file, units, expected):
    header, channels, chtrig = loaded_acq_file

    # set units to test that expected frequency is generated correctly
    header[1][0] = units
    interval, orig_units, orig_names = io.extract_header_items(
        channels, header)
    phys_obj = io.generate_blueprint(channels, chtrig, interval, orig_units,
                                     orig_names)
    assert math.isclose(phys_obj.freq[0], expected)
예제 #6
0
def test_generate_blueprint_items_errors(loaded_lab_file):
    header, channels, chtrig = loaded_lab_file
    # test file without header
    # test when units are not valid
    header[0][1] = ' 1 gHz'
    interval, orig_units, orig_names = io.extract_header_items(
        channels, header)
    with raises(AttributeError) as errorinfo:
        io.generate_blueprint(channels, chtrig, interval, orig_units,
                              orig_names)
    assert 'Interval unit "gHz" is not in a valid frequency' in str(
        errorinfo.value)