示例#1
0
def test_slicing_not_touching_original(time, signal):
    record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"])
    record_sliced = record[0:1]
    assert len(record) == 6
    record_sliced = record[0:2]
    assert len(record) == 6
    record_sliced = record[1:3]
    assert len(record) == 6
    record_sliced = record[1]
    assert len(record) == 6
示例#2
0
def test_slicing(time, signal):
    record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"])
    record_sliced = record[0:1]
    assert record_sliced.time == time[0:1]
    for i, s in enumerate(signal):
        assert record_sliced._signals[i] == s[0:1]
示例#3
0
def test_get_lead_notfound(time, signal):
    record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"])
    assert record.get_lead("MLII") is None
示例#4
0
def test_get_lead(time, signal):
    record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"])
    assert np.array_equal(record.get_lead("I")[:], [1, 2, 3, 4, 5, 6])
    assert np.array_equal(record.get_lead("II")[:], [5, 6, 7, 8, 9, 10])
    assert np.array_equal(record.get_lead("III")[:], [10, 20, 30, 40, 50, 60])
示例#5
0
def test_repr(time, signal):
    record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"])
    assert record.__repr__() == f"Record 100: ['I', 'II', 'III']"
示例#6
0
def test_from_numpy_array_inconsistent_signal_name(time, signal):
    with pytest.raises(ValueError):
        ECGRecord.from_np_array("record_100", time, signal, ["II"])
示例#7
0
def test_from_numpy_array(time, signal):
    record = ECGRecord.from_np_array("record_100", time, signal,
                                     ["I", "II", "III"])
    assert len(record) == len(time)
示例#8
0
def test_from_numpy_array_bad_signal_shape(time, signal):
    with pytest.raises(ValueError):
        ECGRecord.from_np_array("record_100", time, signal, ["II"])
示例#9
0
def test_p_signal_shape(time, signal):
    record = ECGRecord.from_np_array("100", time, signal, ["I", "II", "III"])
    assert np.array_equal(record.p_signal.shape, (3, 6))