Example #1
0
def test_required_from_requested():
    expected = ['F4-T8', 'T4-T8']
    first = Channel(
        **{
            'physical_dimension': 'uV',
            'num_samples_per_record': 20,
            'label': expected[0],
        })
    second = Channel(
        **{
            'physical_dimension': 'uV',
            'num_samples_per_record': 20,
            'label': expected[1]
        })
    reader = Reader(None, [first, second])
    requested = [Label('F4-T4')]
    assert set(reader.required_from_requested(requested)) == set(expected)
Example #2
0
def test_startdatetime():
    expected = datetime(2002, 2, 4, 22, 7, 23)
    header = Header(**{
        'startdate': '04.02.02',
        'starttime': '22.07.23',
    })
    reader = Reader(header, [])
    assert reader.startdatetime == expected
Example #3
0
def test_get_physical_samples_subset(sample_filepath, channel):
    """test Reader.startdatetime"""
    expected = [channel]
    reader = Reader.open(sample_filepath)
    signals = reader.get_physical_samples(labels=expected)
    assert set(signals.keys()) == set(expected)
    other = reader.get_physical_samples()
    assert np.all(signals[expected[0]] == other[expected[0]])
Example #4
0
def test_get_physical_samples(sample_filepath, sample_data):
    """test Reader.startdatetime"""
    reader = Reader.open(sample_filepath)
    signals = reader.get_physical_samples()
    assert set(signals.keys()) == set(sample_data.columns)
    for label, expected in sample_data.items():
        signal = signals[label]
        assert signal.shape == expected.shape, label
        assert signal == pytest.approx(expected, rel=1e-4), label
Example #5
0
def test_duration():
    record_duration = 10
    num_records = 10
    expected = record_duration * num_records
    header = Header(**{
        'record_duration': record_duration,
        'num_records': num_records,
    })
    reader = Reader(header, [])
    assert reader.duration == expected
Example #6
0
def test_get_physical_samples_in_range(sample_filepath, sample_data):
    """test Reader.startdatetime"""
    t0, dt = 1.0, 0.503  # seconds
    reader = Reader.open(sample_filepath)
    signals = reader.get_physical_samples(t0, dt)
    assert set(signals.keys()) == set(sample_data.columns)
    for label, data in sample_data.items():
        expected = data.loc[t0:t0 + dt]
        signal = signals[label]
        assert signal.shape == expected.shape, label
        assert signal == pytest.approx(expected, rel=1e-4), label
Example #7
0
def test_labels_with_derivations():
    expected = ['F4-T8', 'T4-T8', 'F4-T4', 'T4-F4']
    first = Channel(
        **{
            'physical_dimension': 'uV',
            'num_samples_per_record': 20,
            'label': expected[0],
        })
    second = Channel(
        **{
            'physical_dimension': 'uV',
            'num_samples_per_record': 20,
            'label': expected[1]
        })
    reader = Reader(None, [first, second])
    assert set(reader.labels) == set(expected)
Example #8
0
def test_startdatetime(sample_filepath, startdatetime):
    """test Reader.startdatetime"""
    reader = Reader.open(sample_filepath)
    assert reader.startdatetime == startdatetime
Example #9
0
def test_duration(sample_filepath, duration):
    """test Reader.duration"""
    reader = Reader.open(sample_filepath)
    assert reader.duration == duration